Ver Fonte

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
Elias Jarlebring há 10 anos atrás
pai
commit
8d8546868d
1 ficheiros alterados com 4 adições e 0 exclusões
  1. 4 0
      internal/upnp/upnp.go

+ 4 - 0
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
 	}