Documentation ¶
Overview ¶
Package client contains a simple implementation of HTTP 1 client which returns a streaming body.
By default fasthttp puts whole response into the memory. This is fine for small responses but if we use this library to stream huge files, this can cause a lot of problems.
WHen fasthttp will introduce support of streaming bodies, this package should be considered as obsolete.
Index ¶
Constants ¶
const ( // DefaultHTTPTimeout is a default timeout for processing of a single // HTTP request. DefaultHTTPTimeout = 3 * time.Minute // DefaultHTTPPort is a default port for HTTP. DefaultHTTPPort = "80" // DefaultHTTPSPort is a default port for HTTPS. DefaultHTTPSPort = "443" )
const ( // DefaultDialTimeout is a timeout for dialing to the host DefaultDialTimeout = 20 * time.Second // DefaultLimit constraints an amount of connections to the hostname // for PooledDialer. DefaultLimit = 1024 )
Variables ¶
This section is empty.
Functions ¶
func FastHTTPBaseDialer ¶
FastHTTPBaseDialer is a BaseDialer which uses fasthttp.
Types ¶
type BaseDialer ¶
BaseDialer connects to the hostname.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the implementation of HTTP1 client which sets body as a stream.
type Dialer ¶
type Dialer interface { // Dial establishes connection to the given host. Dial(string) (net.Conn, error) // Release returns net.Conn back to the client. Second parameter is // hostname which was used for Dial. Release(net.Conn, string) // NotifyClosed tells Dialer that net.Conn for address is broken. NotifyClosed(string) }
Dialer is a common interface for data structure which dials to hostnames. It's main purpose is to release connections when necessary or notify that some net.Conn is broken.
type PooledDialer ¶
type PooledDialer struct {
// contains filtered or unexported fields
}
PooledDialer is a dialer which manages pools of connections to different hosts.
func NewPooledDialer ¶
func NewPooledDialer(dialer BaseDialer, timeout time.Duration, limit int) (*PooledDialer, error)
NewPooledDialer creates new instance of PooledDialer.
func (*PooledDialer) Dial ¶
func (d *PooledDialer) Dial(addr string) (net.Conn, error)
Dial establishes connection to the given host.
func (*PooledDialer) NotifyClosed ¶
func (d *PooledDialer) NotifyClosed(addr string)
NotifyClosed tells Dialer that net.Conn for address is broken.
type SimpleDialer ¶
type SimpleDialer struct {
// contains filtered or unexported fields
}
SimpleDialer is a dialer which always closes connections when they are not needed. It does not do any pooling.
func NewSimpleDialer ¶
func NewSimpleDialer(base BaseDialer, timeout time.Duration) (*SimpleDialer, error)
NewSimpleDialer returns new instance of SimpleDialer.
func (*SimpleDialer) Dial ¶
func (s *SimpleDialer) Dial(addr string) (net.Conn, error)
Dial establishes connection to the given host.
func (*SimpleDialer) NotifyClosed ¶
func (s *SimpleDialer) NotifyClosed(_ string)
NotifyClosed tells Dialer that net.Conn for address is broken.