Documentation ¶
Index ¶
- Constants
- func BaseTransport(cli *http.Client) *http.Transport
- func MaybeLogRetryAttempt(url string, attempt *retry.Attempt, startTime time.Time)
- func NewHTTPClient(opts *ClientOptions) *http.Client
- func RetryRequest(endpoint string, doRequest func() (*http.Response, error), ...) (resp *http.Response, err error)
- func SetUserAgentFromVersion(version string, extraProds ...string) (restore func())
- func ShouldRetryError(attempt *retry.Attempt, err error) bool
- func ShouldRetryHttpResponse(attempt *retry.Attempt, resp *http.Response) bool
- func UserAgent() string
- type ClientOptions
- type LoggedTransport
- type PerstistentNetworkError
Constants ¶
View Source
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 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 SetUserAgentFromVersion ¶
SetUserAgentFromVersion sets up a user-agent string.
func ShouldRetryError ¶
func ShouldRetryHttpResponse ¶
Types ¶
type ClientOptions ¶
type LoggedTransport ¶
type LoggedTransport struct { Transport http.RoundTripper Key string // contains filtered or unexported fields }
LoggedTransport is an http.RoundTripper that can be used by http.Client to log request/response roundtrips.
type PerstistentNetworkError ¶
type PerstistentNetworkError struct {
Err error
}
func (*PerstistentNetworkError) Error ¶
func (e *PerstistentNetworkError) Error() string
Click to show internal directories.
Click to hide internal directories.