client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoDeadline

func DoDeadline(ctx context.Context, req *protocol.Request, resp *protocol.Response, deadline time.Time, c Doer) error

func DoRequestFollowRedirects

func DoRequestFollowRedirects(ctx context.Context, req *protocol.Request, resp *protocol.Response, url string, maxRedirectsCount int, c Doer) (statusCode int, body []byte, err error)

func DoTimeout

func DoTimeout(ctx context.Context, req *protocol.Request, resp *protocol.Response, timeout time.Duration, c Doer) error

func GetURL

func GetURL(ctx context.Context, dst []byte, url string, c Doer, requestOptions ...config.RequestOption) (statusCode int, body []byte, err error)

func GetURLDeadline

func GetURLDeadline(ctx context.Context, dst []byte, url string, deadline time.Time, c Doer, requestOptions ...config.RequestOption) (statusCode int, body []byte, err error)

func GetURLTimeout

func GetURLTimeout(ctx context.Context, dst []byte, url string, timeout time.Duration, c Doer, requestOptions ...config.RequestOption) (statusCode int, body []byte, err error)

func PostURL

func PostURL(ctx context.Context, dst []byte, url string, postArgs *protocol.Args, c Doer, requestOptions ...config.RequestOption) (statusCode int, body []byte, err error)

func StatusCodeIsRedirect

func StatusCodeIsRedirect(statusCode int) bool

StatusCodeIsRedirect returns true if the status code indicates a redirect.

Types

type DialFunc

type DialFunc func(addr string) (network.Conn, error)

DialFunc must establish connection to addr.

There is no need in establishing TLS (SSL) connection for https. The client automatically converts connection to TLS if HostClient.IsTLS is set.

TCP address passed to DialFunc always contains host and port. Example TCP addr values:

  • foobar.com:80
  • foobar.com:443
  • foobar.com:8080

type Doer

type Doer interface {
	Do(ctx context.Context, req *protocol.Request, resp *protocol.Response) error
}

type HostClient

type HostClient interface {
	Doer
	CloseIdleConnections()
	ShouldRemove() bool
	ConnectionCount() int
}

type HostClientConfig

type HostClientConfig struct {
	Addr string
	Name string

	NoDefaultUserAgentHeader      bool
	DialDualStack                 bool
	DisableHeaderNamesNormalizing bool
	DisablePathNormalizing        bool
	IsTLS                         bool

	TLSConfig *tls.Config

	MaxConns                  int
	MaxIdempotentCallAttempts int
	ReadBufferSize            int
	WriteBufferSize           int
	MaxResponseBodySize       int

	Dial               DialFunc
	RetryIf            RetryIfFunc
	ResponseBodyStream bool

	DialTimeout         time.Duration
	MaxIdleConnDuration time.Duration
	MaxConnDuration     time.Duration
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
	MaxConnWaitTimeout  time.Duration

	ProxyURI *protocol.URI
}

type RetryIfFunc

type RetryIfFunc func(request *protocol.Request) bool

RetryIfFunc signature of retry if function

Request argument passed to RetryIfFunc, if there are any request errors.

Jump to

Keyboard shortcuts

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