From 8d8546868dc10af2bdc75f991cd99ee9b6323e10 Mon Sep 17 00:00:00 2001 From: Elias Jarlebring Date: Sun, 26 Apr 2015 22:31:43 +0200 Subject: [PATCH] Fix to for routers that cannot handle many open HTTP-connections Some routers do not respond when too many subsequent SOAP-requests are sent and will generate an EOF-error in the DefaultClient.Do(req). This modification adds a req.Close = True following the description on http://stackoverflow.com/questions/17714494/golang-http-request-results-in-eof-errors-when-making-multiple-requests-successi --- internal/upnp/upnp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/upnp/upnp.go b/internal/upnp/upnp.go index ea8ad721f..f78d91ac9 100644 --- a/internal/upnp/upnp.go +++ b/internal/upnp/upnp.go @@ -452,6 +452,7 @@ func soapRequest(url, service, function, message string) ([]byte, error) { if err != nil { return resp, err } + req.Close = true 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)) @@ -467,6 +468,9 @@ func soapRequest(url, service, function, message string) ([]byte, error) { r, err := http.DefaultClient.Do(req) if err != nil { + if debug { + l.Debugln(err) + } return resp, err }