aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy/httptransport.go
diff options
context:
space:
mode:
authorWeidiDeng <[email protected]>2024-08-08 20:53:30 +0800
committerGitHub <[email protected]>2024-08-08 06:53:30 -0600
commit21af88fefc9a8239a024f635f1c6fdd9defd7eb7 (patch)
treeb5591814c67c04457dfe4f37d62dd0bf36945d8e /modules/caddyhttp/reverseproxy/httptransport.go
parent52bad451819ca142e66a66e8424821f19cd96358 (diff)
downloadcaddy-21af88fefc9a8239a024f635f1c6fdd9defd7eb7.tar.gz
caddy-21af88fefc9a8239a024f635f1c6fdd9defd7eb7.zip
reverseproxy: Disable keep alive for h2c requests (#6343)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/httptransport.go')
-rw-r--r--modules/caddyhttp/reverseproxy/httptransport.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go
index d42453684..9a82341d0 100644
--- a/modules/caddyhttp/reverseproxy/httptransport.go
+++ b/modules/caddyhttp/reverseproxy/httptransport.go
@@ -446,6 +446,9 @@ func (h *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) {
// if H2C ("HTTP/2 over cleartext") is enabled and the upstream request is
// HTTP without TLS, use the alternate H2C-capable transport instead
if req.URL.Scheme == "http" && h.h2cTransport != nil {
+ // There is no dedicated DisableKeepAlives field in *http2.Transport.
+ // This is an alternative way to disable keep-alive.
+ req.Close = h.Transport.DisableKeepAlives
return h.h2cTransport.RoundTrip(req)
}