httpclient

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

README

NOTICE

This package was copied from the bosh-utils here and here and modified to remove dependencies on errors and logger.

It was chosen to copy this code in order to configure the socks5 proxy settings for tunneling without requiring the user of our software to set the BOSH_ALL_PROXY environment variable.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultClient

func DefaultClient(allProxy string, certPool *x509.CertPool) *http.Client

func InsecureClient

func InsecureClient() *http.Client

func MakeReplayable

func MakeReplayable(r *http.Request) (io.ReadCloser, error)

func New

func New(
	allProxy string,
	insecureSkipVerify,
	externalClient bool,
	disableKeepAlives bool,
	certPool *x509.CertPool,
) *http.Client

func NewAttemptRetryStrategy

func NewAttemptRetryStrategy(
	maxAttempts int,
	delay time.Duration,
	retryable boshretry.Retryable,
) boshretry.RetryStrategy

func SOCKS5DialContextFuncFromAllProxy

func SOCKS5DialContextFuncFromAllProxy(allProxy string, socks5Proxy boshhttp.ProxyDialer) boshhttp.DialContextFunc

func WithClientSessionCache

func WithClientSessionCache(capacity int) tlsconfig.TLSOption

func WithInsecureSkipVerify

func WithInsecureSkipVerify(insecureSkipVerify bool) tlsconfig.TLSOption

Types

type AdjustableClient

type AdjustableClient struct {
	// contains filtered or unexported fields
}

func NewAdjustableClient

func NewAdjustableClient(client AdjustedClient, adjustment Adjustment) AdjustableClient

func (AdjustableClient) Do

type AdjustedClient

type AdjustedClient interface {
	Do(*gohttp.Request) (*gohttp.Response, error)
}

type Adjustment

type Adjustment interface {
	Adjust(req *gohttp.Request, retried bool) error
	NeedsReadjustment(*gohttp.Response) bool
}

type AuthRequestAdjustment

type AuthRequestAdjustment struct {
	// contains filtered or unexported fields
}

func NewAuthRequestAdjustment

func NewAuthRequestAdjustment(
	authFunc func(bool) (string, error),
	client,
	clientSecret string,
) AuthRequestAdjustment

func (AuthRequestAdjustment) Adjust

func (a AuthRequestAdjustment) Adjust(req *http.Request, retried bool) error

func (AuthRequestAdjustment) NeedsReadjustment

func (a AuthRequestAdjustment) NeedsReadjustment(resp *http.Response) bool

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

func NewNetworkSafeRetryClient

func NewNetworkSafeRetryClient(
	delegate Client,
	maxAttempts uint,
	retryDelay time.Duration,
) Client

func NewRetryClient

func NewRetryClient(
	delegate Client,
	maxAttempts uint,
	retryDelay time.Duration,
) Client

type DefaultHTTPClient

type DefaultHTTPClient struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(client Client) *DefaultHTTPClient

func NewHTTPClientOpts

func NewHTTPClientOpts(client Client, opts Opts) *DefaultHTTPClient

func (*DefaultHTTPClient) Delete

func (c *DefaultHTTPClient) Delete(endpoint string) (*http.Response, error)

func (*DefaultHTTPClient) DeleteCustomized

func (c *DefaultHTTPClient) DeleteCustomized(endpoint string, f func(*http.Request)) (*http.Response, error)

func (*DefaultHTTPClient) Get

func (c *DefaultHTTPClient) Get(endpoint string) (*http.Response, error)

func (*DefaultHTTPClient) GetCustomized

func (c *DefaultHTTPClient) GetCustomized(endpoint string, f func(*http.Request)) (*http.Response, error)

func (*DefaultHTTPClient) Post

func (c *DefaultHTTPClient) Post(endpoint string, payload []byte) (*http.Response, error)

func (*DefaultHTTPClient) PostCustomized

func (c *DefaultHTTPClient) PostCustomized(endpoint string, payload []byte, f func(*http.Request)) (*http.Response, error)

func (*DefaultHTTPClient) Put

func (c *DefaultHTTPClient) Put(endpoint string, payload []byte) (*http.Response, error)

func (*DefaultHTTPClient) PutCustomized

func (c *DefaultHTTPClient) PutCustomized(endpoint string, payload []byte, f func(*http.Request)) (*http.Response, error)

type Opts

type Opts struct {
	NoRedactUrlQuery bool
}

type RedirectFunc

type RedirectFunc func(*http.Request, []*http.Request) error

type RequestRetryable

type RequestRetryable struct {
	// contains filtered or unexported fields
}

func NewRequestRetryable

func NewRequestRetryable(
	request *http.Request,
	delegate Client,
	isResponseAttemptable func(*http.Response, error) (bool, error),
) *RequestRetryable

func (*RequestRetryable) Attempt

func (r *RequestRetryable) Attempt() (bool, error)

func (*RequestRetryable) Response

func (r *RequestRetryable) Response() *http.Response

Jump to

Keyboard shortcuts

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