Retry checking refactored using util function.
This commit is contained in:
1 parent
46c4db6b1a
commit
be4d13c0ef
3 files changed
+18
-10
No files matched your search
+5
-7
@@ -105,13 +105,11 @@ func (c *Client) DoRequest(req *Request) (resp *Response, err error) {
|
||||
}
|
||||
|
||||
// Retry on http status codes
|
||||
for _, statusCode := range c.opt.RetryHTTPCodes {
|
||||
if resp.StatusCode == statusCode {
|
||||
if req.retryCounter < c.opt.RetryTimes {
|
||||
req.retryCounter++
|
||||
internal.Logger.Println("Retrying:", req.URL.String(), resp.StatusCode)
|
||||
return c.DoRequest(req)
|
||||
}
|
||||
if internal.ContainsInt(c.opt.RetryHTTPCodes, resp.StatusCode) {
|
||||
if req.retryCounter < c.opt.RetryTimes {
|
||||
req.retryCounter++
|
||||
internal.Logger.Println("Retrying:", req.URL.String(), resp.StatusCode)
|
||||
return c.DoRequest(req)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user