From 2afbbb3400b076b9319833296dcf28949142dfe6 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 27 Oct 2017 14:08:30 -0400 Subject: [PATCH] Only call ConfigureTransport if "h2" is not already in NextProtos. Fixes #3435 --- api/client.go | 15 +++++++++++++-- api/client_test.go | 13 +++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/client.go b/api/client.go index 6e0aa18eea87..d801c4397571 100644 --- a/api/client.go +++ b/api/client.go @@ -282,8 +282,19 @@ func NewClient(c *Config) (*Client, error) { } if tp, ok := c.HttpClient.Transport.(*http.Transport); ok { - if err := http2.ConfigureTransport(tp); err != nil { - return nil, err + if tcc := tp.TLSClientConfig; tcc != nil { + var found bool + for _, proto := range tcc.NextProtos { + if proto == "h2" { + found = true + break + } + } + if !found { + if err := http2.ConfigureTransport(tp); err != nil { + return nil, err + } + } } } diff --git a/api/client_test.go b/api/client_test.go index 3bc866b157b2..a11763411277 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -213,3 +213,16 @@ func TestClientNonTransportRoundTripper(t *testing.T) { t.Fatal(err) } } + +func TestClone(t *testing.T) { + client1, err1 := NewClient(nil) + if err1 != nil { + t.Fatalf("NewClient failed: %v", err1) + } + client2, err2 := client1.Clone() + if err2 != nil { + t.Fatalf("Clone failed: %v", err2) + } + + _ = client2 +}