parnurzeal / gorequest

GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent )
http://parnurzeal.github.io/gorequest/
MIT License
3.44k stars 414 forks source link

Retry implementation is wrong #254

Open bhuvanvenkat-plivo opened 3 years ago

bhuvanvenkat-plivo commented 3 years ago

https://github.com/parnurzeal/gorequest/blob/develop/gorequest.go#L1102

for {
    resp, body, errs = s.getResponseBytes()
    if errs != nil {
        return nil, nil, errs
    }
    if s.isRetryableRequest(resp) {
        resp.Header.Set("Retry-Count", strconv.Itoa(s.Retryable.Attempt))
        break
    }
}

s.getResponseBytes() will be executing the http request. Any error set in s.Errors or errs is not nil isRetryableRequest() check is not performed. Any retry set to the SuperAgent object is not considered.