Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRetryIf added in v0.4.0

func DefaultRetryIf(req *protocol.Request, resp *protocol.Response, err error) bool

DefaultRetryIf Default retry condition, mainly used for idempotent requests. If this cannot be satisfied, you can implement your own retry condition.

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 Doer

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

type DynamicConfig added in v0.2.0

type DynamicConfig struct {
	Addr     string
	ProxyURI *protocol.URI
	IsTLS    bool
}

DynamicConfig is config set which will be confirmed when starts a request.

type HostClient

type HostClient interface {
	Doer
	SetDynamicConfig(dc *DynamicConfig)
	CloseIdleConnections()
	ShouldRemove() bool
	ConnectionCount() int
}

type RetryIfFunc

type RetryIfFunc func(req *protocol.Request, resp *protocol.Response, err error) bool

RetryIfFunc signature of retry if function Judge whether to retry by request,response or error , return true is retry

Jump to

Keyboard shortcuts

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