aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy/reverseproxy.go
diff options
context:
space:
mode:
authorWeidiDeng <[email protected]>2024-02-20 11:25:02 +0800
committerGitHub <[email protected]>2024-02-19 20:25:02 -0700
commit53f7035299a6de0553349e3b5bcabcf422f07b94 (patch)
treeb768bcaf22ac8cd4a75b0e8b1e75bd3d30c7c03d /modules/caddyhttp/reverseproxy/reverseproxy.go
parentb893c8c5f856ba7399ed05c8de82fa5c8158ff00 (diff)
downloadcaddy-53f7035299a6de0553349e3b5bcabcf422f07b94.tar.gz
caddy-53f7035299a6de0553349e3b5bcabcf422f07b94.zip
reverseproxy: use context.WithoutCancel (#6116)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/reverseproxy.go')
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go28
1 files changed, 1 insertions, 27 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 201ff638b..1648b7791 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -783,7 +783,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
// regardless, and we should expect client disconnection in low-latency streaming
// scenarios (see issue #4922)
if h.FlushInterval == -1 {
- req = req.WithContext(ignoreClientGoneContext{req.Context()})
+ req = req.WithContext(context.WithoutCancel(req.Context()))
}
// do the round-trip; emit debug log with values we know are
@@ -1419,32 +1419,6 @@ type handleResponseContext struct {
isFinalized bool
}
-// ignoreClientGoneContext is a special context.Context type
-// intended for use when doing a RoundTrip where you don't
-// want a client disconnection to cancel the request during
-// the roundtrip.
-// This context clears cancellation, error, and deadline methods,
-// but still allows values to pass through from its embedded
-// context.
-//
-// TODO: This can be replaced with context.WithoutCancel once
-// the minimum required version of Go is 1.21.
-type ignoreClientGoneContext struct {
- context.Context
-}
-
-func (c ignoreClientGoneContext) Deadline() (deadline time.Time, ok bool) {
- return
-}
-
-func (c ignoreClientGoneContext) Done() <-chan struct{} {
- return nil
-}
-
-func (c ignoreClientGoneContext) Err() error {
- return nil
-}
-
// proxyHandleResponseContextCtxKey is the context key for the active proxy handler
// so that handle_response routes can inherit some config options
// from the proxy handler.