Skip to content

Commit 677cb70

Browse files
committed
Retry when getting an EOF on HEAD/GET requests because of a Golang bug
1 parent 4ea0c92 commit 677cb70

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

swift.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,15 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
465465
req.Header.Add("X-Auth-Token", authToken)
466466
resp, err = c.doTimeoutRequest(timer, req)
467467
if err != nil {
468+
// Because of https://github.com/golang/go/issues/4677,
469+
// we sometimes get an url.Error error embedding an io.EOF error.
470+
// In that case, we simply retry to send the request
471+
if urlError, ok := err.(*url.Error); ok {
472+
if urlError.Err == io.EOF && (p.Operation == "HEAD" || p.Operation == "GET") {
473+
retries--;
474+
continue
475+
}
476+
}
468477
return
469478
}
470479
// Check to see if token has expired

0 commit comments

Comments
 (0)