Documentation ¶
Index ¶
- type Client
- func (c *Client) ClearCookies() error
- func (c *Client) ClearHeaders()
- func (c *Client) ClearProxy()
- func (c *Client) Do(options RequestOptions) (*http.Response, []byte, error)
- func (c *Client) GetCookies(baseURL string) ([]*http.Cookie, error)
- func (c *Client) SetCookies(URL string, cookieMap map[string]string) error
- func (c *Client) SetFollowRedirects(shouldRedirect bool)
- func (c *Client) SetHeaders(headers map[string]string)
- func (c *Client) SetProxy(proxy string) error
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SetTransport(transport http.RoundTripper)
- type ClientOptions
- type ClientOptionsCookies
- type RequestOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Holds a *http.Client and the specified headers as those can't be saved on the client session directly.
func (*Client) ClearCookies ¶
Clears all cookies on the client.
func (*Client) ClearProxy ¶
func (c *Client) ClearProxy()
Clears the proxy from the client. Warning: This will overwrite the existing transport.
func (*Client) GetCookies ¶
Returns all cookies set on the client.
func (*Client) SetCookies ¶
Sets cookies on the client which will be reused on every request.
func (*Client) SetFollowRedirects ¶
Specify if the client should follow redirects.
func (*Client) SetHeaders ¶
Sets headers on the client which will be reused on every request.
func (*Client) SetTimeout ¶
Sets the timeout duration for the client.
func (*Client) SetTransport ¶
func (c *Client) SetTransport(transport http.RoundTripper)
Sets the transport for the client.
type ClientOptions ¶
type ClientOptions struct { Cookies ClientOptionsCookies // Custom cookies set on the client. FollowRedirects bool // If true, the client will follow redirects. Headers map[string]string // Custom headers set to the client. Proxy string // Custom proxy set to the client. Timeout time.Duration // Set custom request timeout. If nil, 30 * time.Second is used. Transport http.RoundTripper // Set custom transport type. If nil, http.DefaultTransport is used. }
Specifies default values when creating a new Client.
type ClientOptionsCookies ¶
type RequestOptions ¶
type RequestOptions struct { Body io.Reader // Body data to include in the request. Cookies map[string]string // A map of cookies to set for the request. Headers map[string]string // A map of headers to set for the request. Method string // The HTTP-Method. ReadResponseBody bool // Whether the response.Body should be parsed or not. Proxy string // Custom proxy for the request. URL string // URL to perform the request on. }
RequestOptions specifies details when making a new request.