From 5a84124739a809bcdb5830fd385440027ddd910f Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Tue, 15 May 2018 15:12:30 +0200 Subject: [PATCH] Make client underlying HTTP client accessible Signed-off-by: Mathieu Champlon --- client/client.go | 5 +++++ client/interface.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/client/client.go b/client/client.go index b8428128bb..b874b3b522 100644 --- a/client/client.go +++ b/client/client.go @@ -356,6 +356,11 @@ func (cli *Client) DaemonHost() string { return cli.host } +// HTTPClient returns a copy of the HTTP client bound to the server +func (cli *Client) HTTPClient() *http.Client { + return &*cli.client +} + // ParseHostURL parses a url string, validates the string is a host url, and // returns the parsed URL func ParseHostURL(host string) (*url.URL, error) { diff --git a/client/interface.go b/client/interface.go index 8ab25591c0..0487a0b9f3 100644 --- a/client/interface.go +++ b/client/interface.go @@ -4,6 +4,7 @@ import ( "context" "io" "net" + "net/http" "time" "github.com/docker/docker/api/types" @@ -33,6 +34,7 @@ type CommonAPIClient interface { VolumeAPIClient ClientVersion() string DaemonHost() string + HTTPClient() *http.Client ServerVersion(ctx context.Context) (types.Version, error) NegotiateAPIVersion(ctx context.Context) NegotiateAPIVersionPing(types.Ping)