Add Accept header to publish request

This commit is contained in:
Peter Stuifzand 2018-04-08 00:26:58 +02:00
parent 9baab2fda9
commit 27f8c9611d

View File

@ -16,6 +16,10 @@ import (
"time" "time"
) )
func init() {
log.SetFlags(log.Ltime | log.Lshortfile)
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func randStringBytes(n int) string { func randStringBytes(n int) string {
@ -48,7 +52,9 @@ func (handler *subscriptionHandler) handlePublish(w http.ResponseWriter, r *http
log.Printf("publish: topic = %s\n", topic) log.Printf("publish: topic = %s\n", topic)
client := &http.Client{} client := &http.Client{}
res, err := client.Get(topic) req, err := http.NewRequest("GET", topic, nil)
req.Header.Add("Accept", "*/*")
res, err := client.Do(req)
if err != nil { if err != nil {
return err return err
} }
@ -135,7 +141,7 @@ func (handler *subscriptionHandler) handleUnsubscription(w http.ResponseWriter,
} }
func (handler *subscriptionHandler) handleSubscription(w http.ResponseWriter, r *http.Request) error { func (handler *subscriptionHandler) handleSubscription(w http.ResponseWriter, r *http.Request) error {
log.Printf("suscription request received: %s %#v\n", r.URL.String(), r.Form) log.Printf("subscription request received: %s %#v\n", r.URL.String(), r.Form)
callback := r.Form.Get("hub.callback") callback := r.Form.Get("hub.callback")
topic := r.Form.Get("hub.topic") topic := r.Form.Get("hub.topic")
secret := r.Form.Get("hub.secret") secret := r.Form.Get("hub.secret")