Documentation ¶
Overview ¶
Package httpcontrol allows a HTTP transport supporting connection pooling, timeouts & retries.
This Transport is built on top of the standard library transport and augments it with additional features.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stats ¶
type Stats struct { // The RoundTrip request. Request *http.Request // May not always be available. Response *http.Response // Will be set if the RoundTrip resulted in an error. Note that these are // RoundTrip errors and we do not care about the HTTP Status. Error error // Each duration is independent and the sum of all of them is the total // request duration. One or more durations may be zero. Duration struct { Header, Body time.Duration } Retry struct { // Will be incremented for each retry. The initial request will have this // set to 0, and the first retry to 1 and so on. Count uint // Will be set if and only if an error was encountered and a retry is // pending. Pending bool } }
Stats for a RoundTrip.
type Transport ¶
type Transport struct { http.Transport // DialTimeout is the maximum amount of time a dial will wait for // a connect to complete. If Deadline is also set, it may fail // earlier. // // The default is no timeout. // // When using TCP and dialing a host name with multiple IP // addresses, the timeout may be divided between them. // // With or without a timeout, the operating system may impose // its own earlier timeout. For instance, TCP timeouts are // often around 3 minutes. DialTimeout time.Duration // DialKeepAlive specifies the interval between keep-alive // probes for an active network connection. // If zero, keep-alive probes are sent with a default value // (currently 15 seconds), if supported by the protocol and operating // system. Network protocols or operating systems that do // not support keep-alives ignore this field. // If negative, keep-alive probes are disabled. DialKeepAlive time.Duration // RequestTimeout, if non-zero, specifies the amount of time for the entire // request. This includes dialing (if necessary), the response header as well // as the entire body. // // Deprecated: Use Request.WithContext to create a request with a // cancelable context instead. RequestTimeout cannot cancel HTTP/2 // requests. RequestTimeout time.Duration // RetryAfterTimeout, if true, will enable retries for a number of failures // that are probably safe to retry for most cases but, depending on the // context, might not be safe. Retried errors: net.Errors where Timeout() // returns `true` or timeouts that bubble up as url.Error but were originally // net.Error, OpErrors where the request was cancelled (either by this lib or // by the calling code, or finally errors from requests that were cancelled // before the remote side was contacted. RetryAfterTimeout bool // MaxTries, if non-zero, specifies the number of times we will retry on // failure. Retries are only attempted for temporary network errors or known // safe failures. MaxTries uint // Stats allows for capturing the result of a request and is useful for // monitoring purposes. Stats func(*Stats) // contains filtered or unexported fields }
Transport is an implementation of RoundTripper that supports http, https, and http proxies (for either http or https with CONNECT). Transport can cache connections for future re-use, provides various timeouts, retry logic and the ability to track request statistics.
func (*Transport) CancelRequest
deprecated
CancelRequest cancels an in-flight request by closing its connection. CancelRequest should only be called after RoundTrip has returned.
Deprecated: Use Request.WithContext to create a request with a cancelable context instead. CancelRequest cannot cancel HTTP/2 requests.
func (*Transport) CloseIdleConnections ¶
func (t *Transport) CloseIdleConnections()
CloseIdleConnections closes the idle connections.