mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
Fix panic when setting a client http client with no transport (#3437)
Fixes #3436
This commit is contained in:
parent
f0348318e7
commit
42953d6482
2 changed files with 12 additions and 0 deletions
|
|
@ -267,6 +267,9 @@ func NewClient(c *Config) (*Client, error) {
|
|||
if c.HttpClient == nil {
|
||||
c.HttpClient = DefaultConfig().HttpClient
|
||||
}
|
||||
if c.HttpClient.Transport == nil {
|
||||
c.HttpClient.Transport = cleanhttp.DefaultTransport()
|
||||
}
|
||||
|
||||
tp := c.HttpClient.Transport.(*http.Transport)
|
||||
if err := http2.ConfigureTransport(tp); err != nil {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,15 @@ func TestDefaultConfig_envvar(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestClientDefaultHttpClient(t *testing.T) {
|
||||
_, err := NewClient(&Config{
|
||||
HttpClient: http.DefaultClient,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientNilConfig(t *testing.T) {
|
||||
client, err := NewClient(nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue