Only call ConfigureTransport if "h2" is not already in NextProtos.
Fixes #3435
This commit is contained in:
parent
46afada06d
commit
08d9353c60
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue