Skip to content

Commit 366aa78

Browse files
committed
clone the transport TLS config instead of creating a new one, and make sure it'll try HTTP/2 by setting NextProtos
1 parent 9cdda4d commit 366aa78

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

internal/api/proxy.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ func withProxyTransport(baseTransport *http.Transport, proxyURL *url.URL, proxyP
3333
if err != nil {
3434
return nil, err
3535
}
36-
tlsConn := tls.Client(conn, &tls.Config{
37-
ServerName: host,
38-
// Pull InsecureSkipVerify from the target host transport
39-
// so that insecure-skip-verify flag settings are honored for the proxy server
40-
InsecureSkipVerify: baseTransport.TLSClientConfig.InsecureSkipVerify,
41-
})
36+
cfg := baseTransport.TLSClientConfig.Clone()
37+
if cfg.ServerName == "" {
38+
cfg.ServerName = host
39+
}
40+
// Preserve HTTP/2 negotiation to the origin when ForceAttemptHTTP2
41+
// is enabled. Without this, the manual TLS handshake would not
42+
// advertise h2 via ALPN, silently forcing HTTP/1.1.
43+
if baseTransport.ForceAttemptHTTP2 && len(cfg.NextProtos) == 0 {
44+
cfg.NextProtos = []string{"h2", "http/1.1"}
45+
}
46+
tlsConn := tls.Client(conn, cfg)
4247
if err := tlsConn.HandshakeContext(ctx); err != nil {
4348
return nil, err
4449
}

0 commit comments

Comments
 (0)