hashicorp / hashicorp/go-retryablehttp

"Get" returning error on non 2xx response

Open
#200 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
298
PR merge metrics
No merged PRs in 30d

Description

Hello,
This might actually be more of a question than an actual issue:
The `http.Client.Get` doc states that:
```
An error is returned if the Client's CheckRedirect function fails or if there was an HTTP protocol error. A non-2xx response doesn't cause an error.
```
My understanding is that a `retryablehttp.Client` with default configuration would behaves similarly, retrying up to 4 times, and returning the response, no matter what the status code is, as long as there is no error.

But it seems that if the client doesn't get a success status in the configured number of retries, it WILL return an error similar to `Get ...: GET ... giving up after 5 attempt(s)`, instead of returning the response with the non success status code.

Am I misunderstanding the doc?

Anyway, setting the client's `ErrorHandler` to `retryablehttp.PassthroughErrorHandler` seems to give what I expected to be the default behavior.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.