From 91c4ff6009a08900454aa5dd92767af421ae9e64 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 2 Jul 2014 20:28:03 +0200 Subject: [PATCH] Handle query parameters in UPnP control URL (fixes #211) --- upnp/upnp.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/upnp/upnp.go b/upnp/upnp.go index b4afebad9..df9e73fd7 100644 --- a/upnp/upnp.go +++ b/upnp/upnp.go @@ -203,14 +203,26 @@ func getServiceURL(rootURL string) (string, error) { } u, _ := url.Parse(rootURL) - if svc.ControlURL[0] == '/' { - u.Path = svc.ControlURL - } else { - u.Path += svc.ControlURL - } + replaceRawPath(u, svc.ControlURL) return u.String(), nil } +func replaceRawPath(u *url.URL, rp string) { + var p, q string + fs := strings.Split(rp, "?") + p = fs[0] + if len(fs) > 1 { + q = fs[1] + } + + if p[0] == '/' { + u.Path = p + } else { + u.Path += p + } + u.RawQuery = q +} + func soapRequest(url, function, message string) error { tpl := `