Documentation ¶
Index ¶
- Constants
- Variables
- func CheckRedirect(req *http.Request, via []*http.Request) error
- func ParseHostURL(host string) (*url.URL, error)
- type Client
- func (cli *Client) ClientVersion() string
- func (cli *Client) Close() error
- func (cli *Client) CustomHTTPHeaders() map[string]string
- func (cli *Client) DaemonHost() string
- func (cli *Client) Dialer() func(context.Context) (net.Conn, error)
- func (cli *Client) HTTPClient() *http.Client
- func (cli *Client) NegotiateAPIVersionPing(p types.Ping)
- func (cli *Client) SetCustomHTTPHeaders(headers map[string]string)
Constants ¶
const DefaultDockerHost = "unix:///var/run/prizes.sock"
DefaultDockerHost defines os specific default if DOCKER_HOST is unset
Variables ¶
var ErrRedirect = errors.New("unexpected redirect in response")
ErrRedirect is the error returned by checkRedirect when the request is non-GET.
Functions ¶
func CheckRedirect ¶
CheckRedirect specifies the policy for dealing with redirect responses: If the request is non-GET return `ErrRedirect`. Otherwise use the last response.
Go 1.8 changes behavior for HTTP redirects (specifically 301, 307, and 308) in the client . The Docker client (and by extension docker API client) can be made to send a request like POST /containers//start where what would normally be in the name section of the URL is empty. This triggers an HTTP 301 from the daemon. In go 1.8 this 301 will be converted to a GET request, and ends up getting a 404 from the daemon. This behavior change manifests in the client in that before the 301 was not followed and the client did not generate an error, but now results in a message like Error response from daemon: page not found.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the API client that performs all operations against a docker server.
func NewClientWithOpts ¶
NewClientWithOpts initializes a new API client with default values. It takes functors to modify values when creating it, like `NewClientWithOpts(WithVersion(…))` It also initializes the custom http headers to add to each request.
It won't send any version information if the version number is empty. It is highly recommended that you set a version or your client may break if the server is upgraded.
func (*Client) ClientVersion ¶
ClientVersion returns the API version used by this client.
func (*Client) CustomHTTPHeaders ¶
CustomHTTPHeaders returns the custom http headers stored by the client.
func (*Client) DaemonHost ¶
DaemonHost returns the host address used by the client
func (*Client) Dialer ¶
Dialer returns a dialer for a raw stream connection, with HTTP/1.1 header, that can be used for proxying the daemon connection. Used by `docker dial-stdio` (docker/cli#889).
func (*Client) HTTPClient ¶
HTTPClient returns a copy of the HTTP client bound to the server
func (*Client) NegotiateAPIVersionPing ¶
NegotiateAPIVersionPing updates the client version to match the Ping.APIVersion if the ping version is less than the default version. If a manual override is in place, either through the `DOCKER_API_VERSION` environment variable, or if the client was initialized with a fixed version (`opts.WithVersion(xx)`), no negotiation is performed.
func (*Client) SetCustomHTTPHeaders ¶
SetCustomHTTPHeaders that will be set on every HTTP request made by the client. Deprecated: use WithHTTPHeaders when creating the client.