httpclientpool

package
v3.2.11 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// MaxResponseHeaderTimeout is the timeout for response headers
	// to be read from the server (this prevents infinite hang started by server if any)
	// Note: this will be overridden temporarily when using @timeout request annotation
	MaxResponseHeaderTimeout = time.Duration(10) * time.Second
	// HttpTimeoutMultiplier is the multiplier for the http timeout
	HttpTimeoutMultiplier = 3
)

Functions

func Get

func Get(options *types.Options, configuration *Configuration) (*retryablehttp.Client, error)

Get creates or gets a client for the protocol based on custom configuration

func GetHttpTimeout

func GetHttpTimeout(opts *types.Options) time.Duration

GetHttpTimeout returns the http timeout for the client

func GetRawHTTP

func GetRawHTTP(options *types.Options) *rawhttp.Client

GetRawHTTP returns the rawhttp request client

func Init

func Init(options *types.Options) error

Init initializes the clientpool implementation

func SendRawRequest

func SendRawRequest(client *rawhttp.Client, opts *RawHttpRequestOpts) (*http.Response, error)

SendRawRequest sends a raw http request with the provided options and returns http response

Types

type Configuration

type Configuration struct {
	// Threads contains the threads for the client
	Threads int
	// MaxRedirects is the maximum number of redirects to follow
	MaxRedirects int
	// NoTimeout disables http request timeout for context based usage
	NoTimeout bool
	// DisableCookie disables cookie reuse for the http client (cookiejar impl)
	DisableCookie bool
	// FollowRedirects specifies the redirects flow
	RedirectFlow RedirectFlow
	// Connection defines custom connection configuration
	Connection *ConnectionConfiguration
	// ResponseHeaderTimeout is the timeout for response body to be read from the server
	ResponseHeaderTimeout time.Duration
}

Configuration contains the custom configuration options for a client

func (*Configuration) HasStandardOptions

func (c *Configuration) HasStandardOptions() bool

HasStandardOptions checks whether the configuration requires custom settings

func (*Configuration) Hash

func (c *Configuration) Hash() string

Hash returns the hash of the configuration to allow client pooling

type ConnectionConfiguration

type ConnectionConfiguration struct {
	// DisableKeepAlive of the connection
	DisableKeepAlive bool
	// contains filtered or unexported fields
}

ConnectionConfiguration contains the custom configuration options for a connection

func (*ConnectionConfiguration) GetCookieJar

func (cc *ConnectionConfiguration) GetCookieJar() *cookiejar.Jar

func (*ConnectionConfiguration) HasCookieJar

func (cc *ConnectionConfiguration) HasCookieJar() bool

func (*ConnectionConfiguration) SetCookieJar

func (cc *ConnectionConfiguration) SetCookieJar(cookiejar *cookiejar.Jar)

type RawHttpRequestOpts

type RawHttpRequestOpts struct {
	// Method is the http method to use
	Method string
	// URL is the url to request
	URL string
	// Path is request path to use
	Path string
	// Headers is the headers to use
	Headers map[string][]string
	// Body is the body to use
	Body io.Reader
	// Options is more client related options
	Options *rawhttp.Options
}

RawHttpRequestOpts is a configuration for raw http request

type RedirectFlow

type RedirectFlow uint8
const (
	DontFollowRedirect RedirectFlow = iota
	FollowSameHostRedirect
	FollowAllRedirect
)

type WithCustomTimeout

type WithCustomTimeout struct {
	Timeout time.Duration
}

WithCustomTimeout is a configuration for custom timeout

Jump to

Keyboard shortcuts

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