Documentation
¶
Overview ¶
Package cfhttp provides defaults and helpers for building http clients. It serves to help maintain the same HTTP configuration across multiple CloudFoundry components.
Index ¶
- func NewClient(options ...Option) *http.Client
- type Option
- func WithDialTimeout(t time.Duration) Option
- func WithDisableKeepAlives() Option
- func WithIdleConnTimeout(t time.Duration) Option
- func WithMaxIdleConnsPerHost(max int) Option
- func WithRequestTimeout(t time.Duration) Option
- func WithStreamingDefaults() Option
- func WithTCPKeepAliveTimeout(t time.Duration) Option
- func WithTLSConfig(t *tls.Config) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient builds a HTTP client with suitable defaults. The Options can optionally set configuration options on the HTTP client, transport, or net dialer. Options are applied in the order that they are passed in, so it is possible for later Options previous ones.
Types ¶
type Option ¶
type Option func(*config)
Option can be used to configure different parts of the HTTP client, including its internal transport or the connection dialer.
func WithDialTimeout ¶
WithDialTimeout sets the time limit for connecting to the remote address. This includes DNS resolution and retries on multiple IP addresses.
A setting of 0 means no timeout.
func WithDisableKeepAlives ¶
func WithDisableKeepAlives() Option
WithDisableKeepAlives disables keep-alive on every HTTP connection so that every connection is closed as soon as its request is done.
func WithIdleConnTimeout ¶
WithIdleConnTimeout sets the maximum amount of time a keep-alive connection can be idle before it closes itself.
A setting of 0 means no timeout.
func WithMaxIdleConnsPerHost ¶
WithMaxIdleConnsPerHost sets the maximum number of keep-alive connections that can be active at a time per remote host.
A setting of 0 sets means the MaxIdleConnsPerHost is http.DefaultMaxIdleConnsPerHost (2 at the time of writing).
func WithRequestTimeout ¶
WithRequestTimeout sets the total time limit for requests made by this Client.
A setting of 0 means no timeout.
func WithStreamingDefaults ¶
func WithStreamingDefaults() Option
WithStreamingDefaults modifies the HTTP client with defaults that are more suitable for consuming server-sent events on persistent connections.
func WithTCPKeepAliveTimeout ¶
WithTCPKeepAliveTimeout sets the keep-alive period for an active TCP connection.
A setting of 0 disables TCP keep-alives.
Source Files
¶
- client.go
- package.go