skopeo/vendor/github.com/hashicorp/go-retryablehttp
renovate[bot] f17b4c9672
Update module github.com/containers/image/v5 to v5.36.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-15 21:58:37 +00:00
..
.gitignore Add support for Fulcio and Rekor, and --sign-by-sigstore=param-file 2023-01-14 13:33:57 +01:00
.go-version Update module github.com/containers/image/v5 to v5.36.0 2025-07-15 21:58:37 +00:00
.golangci.yml Update module github.com/containers/image/v5 to v5.36.0 2025-07-15 21:58:37 +00:00
cert_error_go119.go Update c/image after https://github.com/containers/image/pull/2408 2024-05-14 00:27:15 +02:00
cert_error_go120.go Update c/image after https://github.com/containers/image/pull/2408 2024-05-14 00:27:15 +02:00
CHANGELOG.md Bump github.com/hashicorp/go-retryablehttp from 0.7.6 to 0.7.7 2024-06-25 14:49:54 +00:00
client.go Update module github.com/containers/image/v5 to v5.36.0 2025-07-15 21:58:37 +00:00
CODEOWNERS Update module github.com/containers/image/v5 to v5.36.0 2025-07-15 21:58:37 +00:00
LICENSE Update module github.com/containers/image/v5 to v5.26.0 2023-06-28 19:04:12 +00:00
Makefile Update module github.com/containers/image/v5 to v5.36.0 2025-07-15 21:58:37 +00:00
README.md Update c/image after https://github.com/containers/image/pull/2408 2024-05-14 00:27:15 +02:00
roundtripper.go Update module github.com/containers/image/v5 to v5.26.0 2023-06-28 19:04:12 +00:00

go-retryablehttp

Build Status Go Documentation

The retryablehttp package provides a familiar HTTP client interface with automatic retries and exponential backoff. It is a thin wrapper over the standard net/http client library and exposes nearly the same public API. This makes retryablehttp very easy to drop into existing programs.

retryablehttp performs automatic retries under certain conditions. Mainly, if an error is returned by the client (connection errors, etc.), or if a 500-range response code is received (except 501), then a retry is invoked after a wait period. Otherwise, the response is returned and left to the caller to interpret.

The main difference from net/http is that requests which take a request body (POST/PUT et. al) can have the body provided in a number of ways (some more or less efficient) that allow "rewinding" the request body if the initial request fails so that the full request can be attempted again. See the godoc for more details.

Version 0.6.0 and before are compatible with Go prior to 1.12. From 0.6.1 onward, Go 1.12+ is required. From 0.6.7 onward, Go 1.13+ is required.

Example Use

Using this library should look almost identical to what you would do with net/http. The most simple example of a GET request is shown below:

resp, err := retryablehttp.Get("/foo")
if err != nil {
    panic(err)
}

The returned response object is an *http.Response, the same thing you would usually get from net/http. Had the request failed one or more times, the above call would block and retry with exponential backoff.

Getting a stdlib *http.Client with retries

It's possible to convert a *retryablehttp.Client directly to a *http.Client. This makes use of retryablehttp broadly applicable with minimal effort. Simply configure a *retryablehttp.Client as you wish, and then call StandardClient():

retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 10

standardClient := retryClient.StandardClient() // *http.Client

For more usage and examples see the pkg.go.dev.