poolhttp

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP client that uses a sync.Pool to create new and reuse HTTP clients. It implements the [provisioner.HTTPClient] and Transporter interfaces. This is the HTTP client used by the provisioners.

func New

func New(fn func() *http.Client) *Client

New creates a new poolhttp Client, the sync.Pool will initialize a new *http.Client with the given function.

func (*Client) Do

func (c *Client) Do(req *http.Request) (resp *http.Response, err error)

Do sends an HTTP request and returns an HTTP response, following policy (such as redirects, cookies, auth) as configured on the client.

func (*Client) Get

func (c *Client) Get(u string) (resp *http.Response, err error)

Get issues a GET request to the specified URL. If the response is one of the following redirect codes, Get follows the redirect after calling the [Client.CheckRedirect] function:

func (*Client) SetNew

func (c *Client) SetNew(fn func() *http.Client)

SetNew replaces the inner pool with a new sync.Pool with the given New function. This method can be use concurrently with other methods of this package.

func (*Client) Transport

func (c *Client) Transport() *http.Transport

Transport() returns a clone of the http.Client Transport or returns the default transport.

type Transporter

type Transporter interface {
	Transport() *http.Transport
}

Transporter is implemented by custom HTTP clients with a method that returns an *http.Transport.

Jump to

Keyboard shortcuts

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