diff options
author | WeidiDeng <[email protected]> | 2024-05-27 14:53:21 +0800 |
---|---|---|
committer | WeidiDeng <[email protected]> | 2024-05-27 14:53:21 +0800 |
commit | 77394f2f66195771d7437ff54c6ddd1a37cf2a90 (patch) | |
tree | 1c1c00b0e06d5d521224f722d8b5a4677760bf97 | |
parent | f6d2c293e752254769efe21c8d06a16ebad4845e (diff) | |
download | caddy-h2c-proxy-protocol.tar.gz caddy-h2c-proxy-protocol.zip |
disable keep alive for h2c requestsh2c-proxy-protocol
-rw-r--r-- | modules/caddyhttp/reverseproxy/httptransport.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go index 80a498066..a334eb34d 100644 --- a/modules/caddyhttp/reverseproxy/httptransport.go +++ b/modules/caddyhttp/reverseproxy/httptransport.go @@ -439,6 +439,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) } |