Documentation ¶
Overview ¶
Package http handles interacting with HTTP clients and servers.
This package allows you to make HTTP requests through an HTTP proxy even those using an untrusted certificate (eg: signed by an internal CA).
Note that only HTTP Basic authentication is supported for proxy communication at this time.
Index ¶
- type Client
- func (c *Client) Delete(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
- func (c *Client) Get(url string, headers map[string]string) (*http.Response, []byte, error)
- func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Client, *http.Request, error)
- func (c *Client) Options(url string, headers map[string]string) (*http.Response, []byte, error)
- func (c *Client) Patch(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
- func (c *Client) Post(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
- func (c *Client) Put(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
- type ProxyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // ClientCertificates is a list of certificates to pass for client authentication. ClientCertificates []tls.Certificate // DisableSSLVerification disables HTTPS certificate verification when connecting to a server. You should // only do this if you are *really* sure. Otherwise, add the server's certificate to the RootCertificates // pool. DisableSSLVerification bool // RootCertificates is a pool of root CA certificates to trust. RootCertificates *crypto.CertificatePool // contains filtered or unexported fields }
Client represents an HTTP client.
func NewClient ¶
func NewClient(proxyConfig ProxyConfig) *Client
NewClient returns a new HTTP client object.
func (*Client) Delete ¶
func (c *Client) Delete(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
Delete performs a DELETE request for the given URL and returns the raw body byte array.
func (*Client) Get ¶
Get performs a GET request for the given URL and returns the raw body byte array.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Client, *http.Request, error)
NewRequest creates a new HTTP request object using any configured proxy information.
Note that only HTTP Basic authentication is supported for proxied requests.
func (*Client) Options ¶
Options performs an OPTIONS request for the given URL and returns the raw body byte array.
func (*Client) Patch ¶
func (c *Client) Patch(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)
Patch performs a PATCH request for the given URL and returns the raw body byte array.
type ProxyConfig ¶
type ProxyConfig struct { httpproxy.Config // HTTPProxyUser is the username for proxy authentication for HTTP URLs. HTTPProxyUser string // HTTPProxyPass is the password for proxy authentication for HTTP URLs. HTTPProxyPass string // HTTPSProxyUser is the username for proxy authentication for HTTPS URLs. HTTPSProxyUser string // HTTPSProxyPass is the password for proxy authentication for HTTPS URLs. HTTPSProxyPass string }
ProxyConfig holds the full configuration for proxy settings used by HTTP clients.