From 8f2ad6418d8ecbf7f2ea139b50321bb53bb28c08 Mon Sep 17 00:00:00 2001 From: Elias Jarlebring Date: Sun, 26 Apr 2015 11:08:13 +0200 Subject: [PATCH 1/2] Fix capitalization in HTTP-header in SOAP request (fixes #1696) Some routers are sensitive to the capitalization in "SOAPAction" in the HTTP-header in SOAP request. This modification follows the recommendation of preserving caps in HTTP-headers in go described on http://stackoverflow.com/questions/26351716/how-to-keep-key-case-sensitive-in-request-header-using-golang?lq=1 --- internal/upnp/upnp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/upnp/upnp.go b/internal/upnp/upnp.go index ea8ad721..20e8bc30 100644 --- a/internal/upnp/upnp.go +++ b/internal/upnp/upnp.go @@ -454,7 +454,7 @@ func soapRequest(url, service, function, message string) ([]byte, error) { } req.Header.Set("Content-Type", `text/xml; charset="utf-8"`) req.Header.Set("User-Agent", "syncthing/1.0") - req.Header.Set("SOAPAction", fmt.Sprintf(`"%s#%s"`, service, function)) + req.Header["SOAPAction"]=[]string{fmt.Sprintf(`"%s#%s"`, service, function)} // Enforce capitalization in header-entry for sensitive routers. See issue #1696 req.Header.Set("Connection", "Close") req.Header.Set("Cache-Control", "no-cache") req.Header.Set("Pragma", "no-cache") From d9da02b7a841c8581cc67e381c6760b2403b4867 Mon Sep 17 00:00:00 2001 From: jarlebring Date: Sun, 26 Apr 2015 12:37:37 +0200 Subject: [PATCH 2/2] Formatting with gofmt --- internal/upnp/upnp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/upnp/upnp.go b/internal/upnp/upnp.go index 20e8bc30..f9e2f42d 100644 --- a/internal/upnp/upnp.go +++ b/internal/upnp/upnp.go @@ -454,7 +454,7 @@ func soapRequest(url, service, function, message string) ([]byte, error) { } req.Header.Set("Content-Type", `text/xml; charset="utf-8"`) req.Header.Set("User-Agent", "syncthing/1.0") - req.Header["SOAPAction"]=[]string{fmt.Sprintf(`"%s#%s"`, service, function)} // Enforce capitalization in header-entry for sensitive routers. See issue #1696 + req.Header["SOAPAction"] = []string{fmt.Sprintf(`"%s#%s"`, service, function)} // Enforce capitalization in header-entry for sensitive routers. See issue #1696 req.Header.Set("Connection", "Close") req.Header.Set("Cache-Control", "no-cache") req.Header.Set("Pragma", "no-cache")