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
This commit is contained in:
Elias Jarlebring 2015-04-26 22:31:43 +02:00
parent 73b9d5c5f9
commit 8d8546868d

View File

@ -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
}