Topic and callback should be absolute urls
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2019-03-20 00:00:00 +01:00
parent 72d161add4
commit 4ef5b7b2dd

View File

@ -154,16 +154,23 @@ func (handler *subscriptionHandler) handleSubscription(w http.ResponseWriter, r
callbackURL, err := url.Parse(callback)
if callback == "" || err != nil {
http.Error(w, "Can not parse callback url", 400)
log.Printf("Can not parse callback url: %s\n", callback)
http.Error(w, "cannot parse callback url", 400)
log.Printf("cannot parse callback url: %s", callback)
return err
}
if !callbackURL.IsAbs() {
http.Error(w, "callback url is not absolute", 400)
return fmt.Errorf("callback url is not absolute: %s", callback)
}
topicURL, err := url.Parse(topic)
if topic == "" || err != nil {
http.Error(w, "Can't parse topic url", 400)
log.Printf("Can't parse topic url: %s\n", topic)
return err
http.Error(w, "cannot parse topic url", 400)
return fmt.Errorf("cannot parse topic url: %s\n", topic)
}
if !topicURL.IsAbs() {
http.Error(w, "topic url is not absolute", 400)
return fmt.Errorf("topic url is not absolute: %s", topic)
}
log.Println("subscribe: sending 202 header request accepted")