From 232944cc1531c4a0377a960dccdf8a4b263589d3 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 21 Oct 2016 05:41:54 +0000 Subject: [PATCH] client: add accessor methods for client.customHTTPHeaders Added two methods: - *Client.CustomHTTPHeaders() map[string]string - *Client.SetCustomHTTPHeaders(headers map[string]string) Signed-off-by: Akihiro Suda --- client.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 31a311e7d5..4c0f097e53 100644 --- a/client.go +++ b/client.go @@ -212,12 +212,13 @@ func (cli *Client) getAPIPath(p string, query url.Values) string { // ClientVersion returns the version string associated with this // instance of the Client. Note that this value can be changed // via the DOCKER_API_VERSION env var. +// This operation doesn't acquire a mutex. func (cli *Client) ClientVersion() string { return cli.version } // UpdateClientVersion updates the version string associated with this -// instance of the Client. +// instance of the Client. This operation doesn't acquire a mutex. func (cli *Client) UpdateClientVersion(v string) { if !cli.manualOverride { cli.version = v @@ -244,3 +245,19 @@ func ParseHost(host string) (string, string, string, error) { } return proto, addr, basePath, nil } + +// CustomHTTPHeaders returns the custom http headers associated with this +// instance of the Client. This operation doesn't acquire a mutex. +func (cli *Client) CustomHTTPHeaders() map[string]string { + m := make(map[string]string) + for k, v := range cli.customHTTPHeaders { + m[k] = v + } + return m +} + +// SetCustomHTTPHeaders updates the custom http headers associated with this +// instance of the Client. This operation doesn't acquire a mutex. +func (cli *Client) SetCustomHTTPHeaders(headers map[string]string) { + cli.customHTTPHeaders = headers +}