Don't overwrite Transport's TLS config if it's been set

This commit is contained in:
Kyle Havlovitz 2017-05-24 13:45:19 -07:00
parent 04f1ff78f8
commit 4e44db87e3
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
1 changed files with 10 additions and 7 deletions

View File

@ -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
}