hashicorp / hashicorp/go-retryablehttp
Cannot read the response body inside the `Backoff` function (I think)
- Dominant language
- Go
- Stars
- 2.3k
- Forks
- 298
- PR merge metrics
- No merged PRs in 30d
Description
From my testing, if you try to read the response body in the `Backoff` function, you get an error:
```
http2: response body closed
```
Is there any way to access the response body within that function? (In our case, the 'retry after' information is in the body of the response)
The code I'm testing is:
```
func newClient() http.Client {
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 3
retryClient.Backoff = LisaTest
return retryClient
}
func TestBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
if resp != nil {
var target map[string]interface{}
err := json.NewDecoder(resp.Body).Decode(&target)
spew.Dump(err)
spew.Dump(target)
}
return 1 * time.Second
}
```
I could well be being thick here - would love to know if we're missing something simple (or it's some part of our implementation that I've missed)!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.