Merge pull request #3072 from hashicorp/api-httpclient

Tweaks to api's TLS logic in NewClient
This commit is contained in:
Kyle Havlovitz 2017-05-26 09:11:20 -07:00 committed by GitHub
commit c897d851aa
1 changed files with 10 additions and 11 deletions

View File

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