Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 09:30 UTC
reverseproxy: Disable keep alive for h2c requests (#6343)
WeidiDeng committed
Aug 8, 2024 at 20:53 UTC
21af88fefc9a8239a024f635f1c6fdd9defd7eb7
1 file changed
+3
modules/caddyhttp/reverseproxy/httptransport.go
+3
@@ -446,6 +446,9 @@ func (h *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) {
446
// if H2C ("HTTP/2 over cleartext") is enabled and the upstream request is
447
// HTTP without TLS, use the alternate H2C-capable transport instead
448
if req.URL.Scheme == "http" && h.h2cTransport != nil {
449
+ // There is no dedicated DisableKeepAlives field in *http2.Transport.
450
+ // This is an alternative way to disable keep-alive.
451
+ req.Close = h.Transport.DisableKeepAlives
452
return h.h2cTransport.RoundTrip(req)
453
}
454