Documentation
¶
Index ¶
- Variables
- func AutomaticContentLength(enable bool)
- func AutomaticHostHeader(enable bool)
- func Do(conn Conn, req *http.Request) (*client.Request, *http.Response, error)
- func DoRaw(conn Conn, method, url, uripath string, headers map[string][]string, ...) (*client.Request, *http.Response, error)
- func DoRawWithOptions(conn Conn, method, url, uripath string, headers map[string][]string, ...) (*client.Request, *http.Response, error)
- func Dor(conn Conn, req *retryablehttp.Request) (*client.Request, *http.Response, error)
- func DumpRequestRaw(method, url, uripath string, headers map[string][]string, body io.Reader, ...) ([]byte, error)
- func Get(conn Conn, url string) (*client.Request, *http.Response, error)
- func Post(conn Conn, url string, mimetype string, r io.Reader) (*client.Request, *http.Response, error)
- func TlsHandshake(conn net.Conn, addr string, timeout time.Duration) (net.Conn, error)
- type Client
- func (c *Client) Close()
- func (c *Client) CreateConnection(url string, options *Options) (Conn, error)
- func (c *Client) Do(conn Conn, req *http.Request) (*client.Request, *http.Response, error)
- func (c *Client) DoRaw(conn Conn, method, url, uripath string, headers map[string][]string, ...) (*client.Request, *http.Response, error)
- func (c *Client) DoRawWithOptions(conn Conn, method, url, uripath string, headers map[string][]string, ...) (*client.Request, *http.Response, error)
- func (c *Client) Dor(conn Conn, req *retryablehttp.Request) (*client.Request, *http.Response, error)
- func (c *Client) Get(conn Conn, url string) (*client.Request, *http.Response, error)
- func (c *Client) Head(conn Conn, url string) (*client.Request, *http.Response, error)
- func (c *Client) Post(conn Conn, url string, mimetype string, body io.Reader) (*client.Request, *http.Response, error)
- type Conn
- type Dialer
- type Options
- type PipelineClient
- func (c *PipelineClient) Do(req *http.Request) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) DoRaw(method, url, uripath string, headers map[string][]string, body io.Reader, ...) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) DoRawWithOptions(method, url, uripath string, headers map[string][]string, body io.Reader, ...) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) Dor(req *retryablehttp.Request) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) Get(url string) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) Head(url string) (*clientpipeline.Request, *http.Response, error)
- func (c *PipelineClient) Post(url string, mimetype string, body io.Reader) (*clientpipeline.Request, *http.Response, error)
- type PipelineOptions
- type RedirectStatus
- type StatusError
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = Client{ Options: DefaultOptions, // contains filtered or unexported fields }
DefaultClient is the default HTTP client for doing raw requests
var DefaultOptions = &Options{ Timeout: 30 * time.Second, FollowRedirects: true, MaxRedirects: 10, AutomaticHostHeader: true, AutomaticContentLength: true, }
DefaultOptions is the default configuration options for the client
var DefaultPipelineOptions = PipelineOptions{ Timeout: 30 * time.Second, MaxConnections: 5, MaxPendingRequests: 100, AutomaticHostHeader: true, AutomaticContentLength: true, }
DefaultPipelineOptions is the default options for pipelined http client
Functions ¶
func AutomaticContentLength ¶
func AutomaticContentLength(enable bool)
AutomaticContentLength performs automatic calculation of request content length.
func AutomaticHostHeader ¶
func AutomaticHostHeader(enable bool)
AutomaticHostHeader sets Host header for requests automatically
func DoRaw ¶
func DoRaw(conn Conn, method, url, uripath string, headers map[string][]string, body io.Reader, rawBuffer []byte) (*client.Request, *http.Response, error)
DoRaw does a raw request with some configuration
func DoRawWithOptions ¶
func DoRawWithOptions(conn Conn, method, url, uripath string, headers map[string][]string, body io.Reader, rawBuffer []byte, options *Options) (*client.Request, *http.Response, error)
DoRawWithOptions does a raw request with some configuration
func DumpRequestRaw ¶
func DumpRequestRaw(method, url, uripath string, headers map[string][]string, body io.Reader, rawBuffer []byte, options *Options) ([]byte, error)
DumpRequestRaw to string
Types ¶
type Client ¶
type Client struct { Options *Options // contains filtered or unexported fields }
Client is a client for making raw http requests with go
func (*Client) CreateConnection ¶
func (*Client) DoRaw ¶
func (c *Client) DoRaw(conn Conn, method, url, uripath string, headers map[string][]string, body io.Reader, rawBuffer []byte) (*client.Request, *http.Response, error)
DoRaw does a raw request with some configuration
func (*Client) DoRawWithOptions ¶
func (c *Client) DoRawWithOptions(conn Conn, method, url, uripath string, headers map[string][]string, body io.Reader, rawBuffer []byte, options *Options) (*client.Request, *http.Response, error)
DoRawWithOptions performs a raw request with additional options
func (*Client) Dor ¶
func (c *Client) Dor(conn Conn, req *retryablehttp.Request) (*client.Request, *http.Response, error)
Dor sends a retryablehttp request and returns the response
type Conn ¶
type Conn interface { client.Client io.Closer SetTimeout(duration time.Duration) Release() Stop() error }
Conn is an interface implemented by a connection
type Dialer ¶
type Dialer interface { Dial(protocol, addr string, options *Options) (Conn, error) // Dial dials a remote http server returning a Conn. DialWithProxy(protocol, addr, proxyURL string, timeout time.Duration, options *Options) (Conn, error) DialTimeout(protocol, addr string, timeout time.Duration, options *Options) (Conn, error) // Dial dials a remote http server with timeout returning a Conn. }
Dialer can dial a remote HTTP server.
type Options ¶
type Options struct { Timeout time.Duration FollowRedirects bool MaxRedirects int AutomaticHostHeader bool AutomaticContentLength bool CustomHeaders client.Headers ForceReadAllBody bool // ignores content length and reads all body CustomRawBytes []byte Proxy string ProxyDialTimeout time.Duration SNI string FastDialer *fastdialer.Dialer }
Options contains configuration options for rawhttp client
type PipelineClient ¶
type PipelineClient struct {
// contains filtered or unexported fields
}
PipelineClient is a client for making pipelined http requests
func NewPipelineClient ¶
func NewPipelineClient(ctx context.Context, options PipelineOptions) *PipelineClient
NewPipelineClient creates a new pipelined http request client
func (*PipelineClient) Do ¶
func (c *PipelineClient) Do(req *http.Request) (*clientpipeline.Request, *http.Response, error)
Do sends a http request and returns a response
func (*PipelineClient) DoRaw ¶
func (c *PipelineClient) DoRaw(method, url, uripath string, headers map[string][]string, body io.Reader, raw []byte) (*clientpipeline.Request, *http.Response, error)
DoRaw does a raw request with some configuration
func (*PipelineClient) DoRawWithOptions ¶
func (c *PipelineClient) DoRawWithOptions(method, url, uripath string, headers map[string][]string, body io.Reader, raw []byte, options PipelineOptions) (*clientpipeline.Request, *http.Response, error)
DoRawWithOptions performs a raw request with additional options
func (*PipelineClient) Dor ¶
func (c *PipelineClient) Dor(req *retryablehttp.Request) (*clientpipeline.Request, *http.Response, error)
Dor sends a retryablehttp request and returns a response
func (*PipelineClient) Get ¶
func (c *PipelineClient) Get(url string) (*clientpipeline.Request, *http.Response, error)
Get makes a GET request to a given URL
func (*PipelineClient) Head ¶
func (c *PipelineClient) Head(url string) (*clientpipeline.Request, *http.Response, error)
Head makes a HEAD request to a given URL
type PipelineOptions ¶
type PipelineOptions struct { Dialer clientpipeline.DialFunc Host string Timeout time.Duration MaxConnections int MaxPendingRequests int AutomaticHostHeader bool AutomaticContentLength bool }
PipelineOptions contains options for pipelined http client
type RedirectStatus ¶
RedirectStatus is the current redirect status for the request
type StatusError ¶
StatusError is a HTTP status error object
func (*StatusError) Error ¶
func (s *StatusError) Error() string