aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2024-11-12 13:43:34 -0700
committerMatthew Holt <[email protected]>2024-11-12 14:38:01 -0700
commite4623e72aa83340f0af2d2a82c3c46fcae7f8c92 (patch)
treefb58aaa17e6b7568db469b2f7a6aba20a13fb2f1
parent04a58a9356e27b97a20f00d3d5f125c2e661092c (diff)
downloadcaddy-e4623e72aa83340f0af2d2a82c3c46fcae7f8c92.tar.gz
caddy-e4623e72aa83340f0af2d2a82c3c46fcae7f8c92.zip
reverseproxy: Revert #4952 - don't ignore context cancellation in stream mode
i.e. Revert commit f5dce84a7028d1b116db7fead27ff8b2506baf78 Two years ago, the patch in #4952 was a seemingly necessary way to fix an issue (sort of an edge case), but it broke other more common use cases (see #6666). Now, as of #6669, it seems like the original issue can no longer be replicated, so we are reverting that patch, because it was incorrect anyway. If it turns out the original issue returns, a more proper patch may be in #6669 (even if used as a baseline for a future fix). A potential future fix could be an opt-in setting.
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go17
1 files changed, 1 insertions, 16 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 08be40d62..ba9e5f3fc 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -106,11 +106,6 @@ type Handler struct {
// response is recognized as a streaming response, or if its
// content length is -1; for such responses, writes are flushed
// to the client immediately.
- //
- // Normally, a request will be canceled if the client disconnects
- // before the response is received from the backend. If explicitly
- // set to -1, client disconnection will be ignored and the request
- // will be completed to help facilitate low-latency streaming.
FlushInterval caddy.Duration `json:"flush_interval,omitempty"`
// A list of IP ranges (supports CIDR notation) from which
@@ -773,17 +768,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
}
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
- // if FlushInterval is explicitly configured to -1 (i.e. flush continuously to achieve
- // low-latency streaming), don't let the transport cancel the request if the client
- // disconnects: user probably wants us to finish sending the data to the upstream
- // 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()})
- }
-
- // do the round-trip; emit debug log with values we know are
- // safe, or if there is no error, emit fuller log entry
+ // do the round-trip
start := time.Now()
res, err := h.Transport.RoundTrip(req)
duration := time.Since(start)