Documentation
¶
Overview ¶
Package client provides an HTTP client.
Index ¶
- Constants
- func Download(ctx context.Context, dsn types.URI, filename string) error
- type CharsetRoundTripper
- type Client
- type EncoderRoundTripper
- type LimiterRoundTripper
- type Option
- func WithBaseUri(value string) Option
- func WithBurst(value int) Option
- func WithExpectContinue(value time.Duration) Option
- func WithHeaders(value http.Header) Option
- func WithIdleConnection(value time.Duration) Option
- func WithKeepAlive(value time.Duration) Option
- func WithMaxConnectionsPerHost(value int) Option
- func WithMaxIdleConnections(value int) Option
- func WithProxyURL(value string) Option
- func WithQPS(value float32) Option
- func WithReadBufferSize(value int) Option
- func WithResponseHeader(value time.Duration) Option
- func WithTLSHandshake(value time.Duration) Option
- func WithTimeout(value time.Duration) Option
- func WithWriteBufferSize(value int) Option
- type Options
- type Progress
- type Response
- func (r *Response) Body() io.ReadCloser
- func (r *Response) Close() error
- func (r *Response) ContentLength() int64
- func (r *Response) Cookies() []*nethttp.Cookie
- func (r *Response) Dump(body bool) ([]byte, error)
- func (r *Response) Headers() http.Headers
- func (r *Response) HtmlQuery(expression string) []*html.Node
- func (r *Response) Save(filename string, progressWriter io.Writer) error
- func (r *Response) Status() http.Status
- func (r *Response) Unmarshal(v any) error
Constants ¶
const ( DefaultUserAgent = service.DefaultApplicationName DefaultTimeout = 20 * time.Second DefaultKeepAlive = 30 * time.Second DefaultTLSHandshakeTimeout = 5 * time.Second DefaultExpectContinueTimeout = 1 * time.Second DefaultIdleConnectionTimeout = 60 * time.Second DefaultResponseHeaderTimeout = 5 * time.Second DefaultMaxIdleConnections = 10 DefaultMaxConnectionsPerHost = 10 DefaultWriteBufferSize = 4 * 1024 DefaultReadBufferSize = 4 * 1024 DefaultQPS = 10 DefaultBurst = 100 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CharsetRoundTripper ¶
type CharsetRoundTripper struct {
// contains filtered or unexported fields
}
CharsetRoundTripper is a tripper that applies charset to response.
type Client ¶
type Client struct { *Options // contains filtered or unexported fields }
Client is an HTTP client.
type EncoderRoundTripper ¶
type EncoderRoundTripper struct {
// contains filtered or unexported fields
}
EncoderRoundTripper is a tripper that applies encoding to response.
type LimiterRoundTripper ¶
type LimiterRoundTripper struct {
// contains filtered or unexported fields
}
LimiterRoundTripper is a tripper that applies rate limiting to requests.
type Option ¶
type Option func(o *Options)
Option represents the service option.
func WithExpectContinue ¶
WithExpectContinue sets the expect continue.
func WithIdleConnection ¶
WithIdleConnection sets the idle connection.
func WithKeepAlive ¶
WithKeepAlive sets the keep alive.
func WithMaxConnectionsPerHost ¶
WithMaxConnectionsPerHost sets the max connections per host.
func WithMaxIdleConnections ¶
WithMaxIdleConnections sets the max idle connections.
func WithReadBufferSize ¶
WithReadBufferSize sets the read buffer size.
func WithResponseHeader ¶
WithResponseHeader sets the response header.
func WithTLSHandshake ¶
WithTLSHandshake sets the tls handshake.
func WithWriteBufferSize ¶
WithWriteBufferSize sets the write buffer size.
type Options ¶
type Options struct { BaseUri types.URI `json:"base_uri"` Headers nethttp.Header `json:"headers"` ProxyURL types.URI `json:"proxy_url"` MaxIdleConnections int `json:"max_idle_connections"` MaxConnectionsPerHost int `json:"max_connections_per_host"` WriteBufferSize int `json:"write_buffer_size"` ReadBufferSize int `json:"read_buffer_size"` Timeout time.Duration `json:"timeout"` KeepAlive time.Duration `json:"keep_alive"` TLSHandshake time.Duration `json:"tls_handshake"` ExpectContinue time.Duration `json:"expect_continue"` IdleConnection time.Duration `json:"idle_connection"` ResponseHeader time.Duration `json:"response_header"` QPS float32 `json:"qps"` Burst int `json:"burst"` }
Options is an HTTP client options.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress is a progress.
func NewProgress ¶
NewProgress creates a new progress for a download.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is an HTTP response.
func (*Response) Body ¶
func (r *Response) Body() io.ReadCloser