From 04f1ff78f8bbaa054043586ceb944fc75ebbad54 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Wed, 24 May 2017 11:40:21 -0700 Subject: [PATCH 1/2] Remove superfluous default HttpClient check in NewClient --- api/api.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/api/api.go b/api/api.go index 2225dd3bf3..1353979df6 100644 --- a/api/api.go +++ b/api/api.go @@ -369,10 +369,6 @@ func NewClient(config *Config) (*Client, error) { config.Transport = defConfig.Transport } - if config.HttpClient == nil { - config.HttpClient = defConfig.HttpClient - } - if config.TLSConfig.Address == "" { config.TLSConfig.Address = defConfig.TLSConfig.Address } From 4e44db87e3c80f24837a11056c3b56fbb204eeee Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Wed, 24 May 2017 13:45:19 -0700 Subject: [PATCH 2/2] Don't overwrite Transport's TLS config if it's been set --- api/api.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/api/api.go b/api/api.go index 1353979df6..6f90ed5d60 100644 --- a/api/api.go +++ b/api/api.go @@ -430,17 +430,20 @@ func NewClient(config *Config) (*Client, error) { // NewHttpClient returns an http client configured with the given Transport and TLS // config. func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client, error) { - tlsClientConfig, err := SetupTLSConfig(&tlsConf) - - if err != nil { - return nil, err - } - - transport.TLSClientConfig = tlsClientConfig client := &http.Client{ Transport: transport, } + if transport.TLSClientConfig == nil { + tlsClientConfig, err := SetupTLSConfig(&tlsConf) + + if err != nil { + return nil, err + } + + transport.TLSClientConfig = tlsClientConfig + } + return client, nil }