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 32068f7025
commit 6092d2c2cc
No known key found for this signature in database
GPG key ID: 8A5E6B173056AD6C

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
}