Disable keep alives, fix return on last retry. #297

This commit is contained in:
Andrey Smirnov
2015-09-24 12:21:31 +03:00
parent 76bf7cba04
commit 1e4d825d36
+5 -1
View File
@@ -43,7 +43,8 @@ func NewClient(rt *ResilientTransport) *http.Client {
} }
return c, nil return c, nil
}, },
Proxy: http.ProxyFromEnvironment, DisableKeepAlives: true,
Proxy: http.ProxyFromEnvironment,
} }
// TODO: Would be nice is ResilientTransport allowed clients to initialize // TODO: Would be nice is ResilientTransport allowed clients to initialize
// with http.Transport attributes. // with http.Transport attributes.
@@ -77,6 +78,9 @@ func (t *ResilientTransport) tries(req *http.Request) (res *http.Response, err e
if !t.ShouldRetry(req, res, err) { if !t.ShouldRetry(req, res, err) {
break break
} }
if try == MaxTries-1 {
break
}
if res != nil { if res != nil {
res.Body.Close() res.Body.Close()
} }