parent
326f0cfa2f
commit
5c292c61c6
1437 changed files with 208886 additions and 87131 deletions
9
vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md
generated
vendored
Normal file
9
vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
## 0.7.4 (Jun 6, 2023)
|
||||
|
||||
BUG FIXES
|
||||
|
||||
- client: fixing an issue where the Content-Type header wouldn't be sent with an empty payload when using HTTP/2 [GH-194]
|
||||
|
||||
## 0.7.3 (May 15, 2023)
|
||||
|
||||
Initial release
|
||||
1
vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS
generated
vendored
Normal file
1
vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
* @hashicorp/release-engineering
|
||||
2
vendor/github.com/hashicorp/go-retryablehttp/LICENSE
generated
vendored
2
vendor/github.com/hashicorp/go-retryablehttp/LICENSE
generated
vendored
|
|
@ -1,3 +1,5 @@
|
|||
Copyright (c) 2015 HashiCorp, Inc.
|
||||
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
|
|
|||
19
vendor/github.com/hashicorp/go-retryablehttp/README.md
generated
vendored
19
vendor/github.com/hashicorp/go-retryablehttp/README.md
generated
vendored
|
|
@ -45,25 +45,6 @@ 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.
|
||||
|
||||
## Retrying cases that fail after a seeming success
|
||||
|
||||
It's possible for a request to succeed in the sense that the expected response headers are received, but then to encounter network-level errors while reading the response body. In go-retryablehttp's most basic usage, this error would not be retryable, due to the out-of-band handling of the response body. In some cases it may be desirable to handle the response body as part of the retryable operation.
|
||||
|
||||
A toy example (which will retry the full request and succeed on the second attempt) is shown below:
|
||||
|
||||
```go
|
||||
c := retryablehttp.NewClient()
|
||||
r := retryablehttp.NewRequest("GET", "://foo", nil)
|
||||
handlerShouldRetry := true
|
||||
r.SetResponseHandler(func(*http.Response) error {
|
||||
if !handlerShouldRetry {
|
||||
return nil
|
||||
}
|
||||
handlerShouldRetry = false
|
||||
return errors.New("retryable error")
|
||||
})
|
||||
```
|
||||
|
||||
## Getting a stdlib `*http.Client` with retries
|
||||
|
||||
It's possible to convert a `*retryablehttp.Client` directly to a `*http.Client`.
|
||||
|
|
|
|||
27
vendor/github.com/hashicorp/go-retryablehttp/client.go
generated
vendored
27
vendor/github.com/hashicorp/go-retryablehttp/client.go
generated
vendored
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package retryablehttp 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.
|
||||
|
|
@ -80,8 +83,15 @@ var (
|
|||
type ReaderFunc func() (io.Reader, error)
|
||||
|
||||
// ResponseHandlerFunc is a type of function that takes in a Response, and does something with it.
|
||||
// It only runs if the initial part of the request was successful.
|
||||
// If an error is returned, the client's retry policy will be used to determine whether to retry the whole request.
|
||||
// The ResponseHandlerFunc is called when the HTTP client successfully receives a response and the
|
||||
// CheckRetry function indicates that a retry of the base request is not necessary.
|
||||
// If an error is returned from this function, the CheckRetry policy will be used to determine
|
||||
// whether to retry the whole request (including this handler).
|
||||
//
|
||||
// Make sure to check status codes! Even if the request was completed it may have a non-2xx status code.
|
||||
//
|
||||
// The response body is not automatically closed. It must be closed either by the ResponseHandlerFunc or
|
||||
// by the caller out-of-band. Failure to do so will result in a memory leak.
|
||||
type ResponseHandlerFunc func(*http.Response) error
|
||||
|
||||
// LenReader is an interface implemented by many in-memory io.Reader's. Used
|
||||
|
|
@ -250,10 +260,17 @@ func getBodyReaderAndContentLength(rawBody interface{}) (ReaderFunc, int64, erro
|
|||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
bodyReader = func() (io.Reader, error) {
|
||||
return bytes.NewReader(buf), nil
|
||||
if len(buf) == 0 {
|
||||
bodyReader = func() (io.Reader, error) {
|
||||
return http.NoBody, nil
|
||||
}
|
||||
contentLength = 0
|
||||
} else {
|
||||
bodyReader = func() (io.Reader, error) {
|
||||
return bytes.NewReader(buf), nil
|
||||
}
|
||||
contentLength = int64(len(buf))
|
||||
}
|
||||
contentLength = int64(len(buf))
|
||||
|
||||
// No body provided, nothing to do
|
||||
case nil:
|
||||
|
|
|
|||
3
vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go
generated
vendored
3
vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go
generated
vendored
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package retryablehttp
|
||||
|
||||
import (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue