httpclient

package
v0.0.0-...-0dabf1d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(o *Options) *http.Client

New will create new http client.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a generic stream-oriented network connection.

func (*Conn) Read

func (c *Conn) Read(buf []byte) (n int, err error)

Read will read from the conn.

func (*Conn) Write

func (c *Conn) Write(buf []byte) (n int, err error)

Write will write into the conn.

type Dialer

type Dialer struct {
	*net.Dialer
	// contains filtered or unexported fields
}

Dialer is the dialer the storage used for stream-oriented network connection.

func NewDialer

func NewDialer() *Dialer

NewDialer will create a new dialer with preset default value:

  • dialer connect timeout will be 60s
  • underlying conn read timeout will be 30s
  • underlying conn write timeout will be 30s

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext connects to the address on the named network using the provided context.

func (*Dialer) WithConnectTimeout

func (d *Dialer) WithConnectTimeout(t time.Duration) *Dialer

WithConnectTimeout will configure dialer's timeout

func (*Dialer) WithReadTimeout

func (d *Dialer) WithReadTimeout(t time.Duration) *Dialer

WithReadTimeout will configure underlying conn's read timeout

func (*Dialer) WithWriteTimeout

func (d *Dialer) WithWriteTimeout(t time.Duration) *Dialer

WithWriteTimeout will configure underlying conn's write timeout

type Options

type Options struct {
	// Dialer related options
	DialConnectTimeout time.Duration

	// Underlying connection related options
	ConnReadTimeout  time.Duration
	ConnWriteTimeout time.Duration
}

Options is the httpclient supported options.

Jump to

Keyboard shortcuts

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