cfhttp

package module
v2.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 44

README

cfhttp

Go Report Card Go Reference

Wrapper for official go http package

[!NOTE]

This repository should be imported as code.cloudfoundry.org/cfhttp/v2.

Contributing

See the Contributing.md for more information on how to contribute.

Working Group Charter

This repository is maintained by App Runtime Platform under Diego area.

[!IMPORTANT]

Content in this file is managed by the CI task sync-readme and is generated by CI following a convention.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(options ...Option) *http.Client

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

func WithDialTimeout(t time.Duration) Option

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

func WithIdleConnTimeout(t time.Duration) Option

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

func WithMaxIdleConnsPerHost(max int) Option

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

func WithRequestTimeout(t time.Duration) Option

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

func WithTCPKeepAliveTimeout(t time.Duration) Option

WithTCPKeepAliveTimeout sets the keep-alive period for an active TCP connection.

A setting of 0 disables TCP keep-alives.

func WithTLSConfig

func WithTLSConfig(t *tls.Config) Option

WithTLSConfig sets the TLS configuration on the HTTP client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL