Documentation ¶
Index ¶
- Constants
- func BaseTransport(cli *http.Client) *http.Transport
- func IsCertExpiredOrNotValidYetError(err error) bool
- func MaybeLogRetryAttempt(url string, attempt *retry.Attempt, startTime time.Time)
- func MockResponseHeaderTimeout(d time.Duration) (restore func())
- func NewHTTPClient(opts *ClientOptions) *http.Client
- func NoNetwork(err error) (b bool)
- func RetryRequest(endpoint string, doRequest func() (*http.Response, error), ...) (resp *http.Response, err error)
- func ShouldRetryAttempt(attempt *retry.Attempt, err error) bool
- func ShouldRetryError(err error) (b bool)
- func ShouldRetryHttpResponse(attempt *retry.Attempt, resp *http.Response) bool
- type CertData
- type ClientOptions
- type ExtraSSLCerts
- type ExtraSSLCertsFromDir
- type LoggedTransport
- type PersistentNetworkError
Constants ¶
const ( DebugRequest = debugflag(1 << iota) DebugResponse DebugBody )
set these via the Key environ
Variables ¶
This section is empty.
Functions ¶
func BaseTransport ¶
BaseTransport returns the underlying http.Transport of a client created with NewHTTPClient. It panics if that's not the case. For tests.
func MaybeLogRetryAttempt ¶
func NewHTTPClient ¶
func NewHTTPClient(opts *ClientOptions) *http.Client
NewHTTPClient returns a new http.Client with a LoggedTransport, a Timeout and preservation of range requests across redirects
func NoNetwork ¶
NoNetwork returns true if the error indicates that there is no network connection available, i.e. network unreachable or down or DNS unavailable.
func RetryRequest ¶
func RetryRequest(endpoint string, doRequest func() (*http.Response, error), readResponseBody func(resp *http.Response) error, retryStrategy retry.Strategy) (resp *http.Response, err error)
RetryRequest calls doRequest and read the response body in a retry loop using the given retryStrategy.
func ShouldRetryAttempt ¶
func ShouldRetryError ¶
ShouldRetryError returns true for transient network errors like when the remote side returns a connection reset and it's sensible to retry after a short time.
XXX: Note that currently also NoNetwork(err) errors are reported with true here.
func ShouldRetryHttpResponse ¶
Types ¶
type CertData ¶
CertData contains the raw data of a certificate and the origin of the cert, this is usually a file path on disk and is just used for error reporting.
type ClientOptions ¶
type ExtraSSLCerts ¶
ExtraSSLCerts is an interface that provides a way to add extra SSL certificates to the httputil.Client
type ExtraSSLCertsFromDir ¶
type ExtraSSLCertsFromDir struct {
Dir string
}
ExtraSSLCertsFromDir implements ExtraSSLCerts and provides all the pem encoded certs from the given directory.
func (*ExtraSSLCertsFromDir) Certs ¶
func (e *ExtraSSLCertsFromDir) Certs() ([]*CertData, error)
Certs returns a slice CertData or an error.
type LoggedTransport ¶
type LoggedTransport struct { Transport http.RoundTripper Key string MayLogBody bool }
LoggedTransport is an http.RoundTripper that can be used by http.Client to log request/response roundtrips.
type PersistentNetworkError ¶
type PersistentNetworkError struct {
Err error
}
func (*PersistentNetworkError) Error ¶
func (e *PersistentNetworkError) Error() string