Documentation ¶
Index ¶
Constants ¶
const ( StatusCodeRetryOther = http.StatusPermanentRedirect StatusCodeRetryTemporaryRedirect = http.StatusTemporaryRedirect StatusCodeThrottle = http.StatusTooManyRequests )
Variables ¶
This section is empty.
Functions ¶
func DrainBody ¶
DrainBody reads then closes a response's body if it is non-nil. This function should be deferred before a response reference is discarded.
func LocationFromError ¶ added in v2.13.0
LocationFromError retrieves the 'location' parameter from the provided werror. If the error is not a werror or does not have the location param, ok is false.
The default client error decoder sets the location parameter on its returned errors if the status code is 3xx and a location is set in the response header
func StatusCodeFromError ¶
StatusCodeFromError retrieves the 'statusCode' parameter from the provided werror. If the error is not a werror or does not have the statusCode param, ok is false.
The default client error decoder sets the statusCode parameter on its returned errors. Note that, if a custom error decoder is used, this function will only return a status code for the error if the custom decoder sets a 'statusCode' parameter on the error.
Types ¶
type RequestRetrier ¶ added in v2.3.0
type RequestRetrier struct {
// contains filtered or unexported fields
}
RequestRetrier manages URIs for an HTTP client, providing an API which determines whether requests should be retries and supplying the correct URL for the client to retry. In the case of servers in a service-mesh, requests will never be retried and the mesh URI will only be returned on the first call to GetNextURI
func NewRequestRetrier ¶ added in v2.3.0
func NewRequestRetrier(uris []string, retrier retry.Retrier, maxAttempts int) *RequestRetrier
NewRequestRetrier creates a new request retrier. Regardless of maxAttempts, mesh URIs will never be retried.
func (*RequestRetrier) GetNextURI ¶ added in v2.3.0
func (r *RequestRetrier) GetNextURI(resp *http.Response, respErr error) (uri string, isRelocated bool)
GetNextURI returns the next URI a client should use, or empty string if no suitable URI remaining to retry. isRelocated is true when the URI comes from a redirect's Location header. In this case, it already includes the request path.