fasthttp_client

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxConns           = 10240
	DefaultMaxConnWaitTimeout = time.Second * 60
	DefaultMaxRedirectCount   = 2
)

Variables

This section is empty.

Functions

func DebugHandleFun added in v0.9.0

func DebugHandleFun(w http.ResponseWriter, r *http.Request)

func Dial added in v0.9.0

func Dial(addr string) (net.Conn, error)

func ProxyTimeout

func ProxyTimeout(scheme string, host string, node eocontext.INode, req *fasthttp.Request, resp *fasthttp.Response, timeout time.Duration) error

Types

type Client

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

Client implements http client.

Copying Client by value is prohibited. Create new instance instead.

It is safe calling Client methods from concurrently running goroutines.

The fields of a Client should not be changed while it is in use.

func (*Client) ProxyTimeout

func (c *Client) ProxyTimeout(addr string, host string, req *fasthttp.Request, resp *fasthttp.Response, timeout time.Duration) error

ProxyTimeout performs the given request and waits for response during the given timeout duration.

Request must contain at least non-zero RequestURI with full url (including scheme and host) or non-zero Host header + RequestURI.

Client determines the server to be requested in the following order:

  • from RequestURI if it contains full url with scheme and host;
  • from Host header otherwise.

The function doesn't follow redirects. Use Get* for following redirects.

Response is ignored if resp is nil.

ErrTimeout is returned if the response wasn't returned during the given timeout.

ErrNoFreeConns is returned if all Client.MaxConnsPerHost connections to the requested host are busy.

It is recommended obtaining req and resp via AcquireRequest and AcquireResponse in performance-critical code.

Warning: ProxyTimeout does not terminate the request itself. The request will continue in the background and the response will be discarded. If requests take too long and the connection pool gets filled up please try setting a ReadTimeout.

type CountItem added in v0.9.0

type CountItem struct {
	Time       string `json:"time"`
	DialCount  int64  `json:"dial_count"`
	CloseCount int64  `json:"close_count"`
}

Jump to

Keyboard shortcuts

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