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, 05:45 UTC
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.
Matthew Holt committed
Nov 12, 2024 at 13:43 UTC
238f1108e6600049d9041abc88db24526ee4f882
1 file changed
-14
modules/caddyhttp/reverseproxy/reverseproxy.go
-14
@@ -108,11 +108,6 @@ type Handler struct {
108
// response is recognized as a streaming response, or if its
109
// content length is -1; for such responses, writes are flushed
110
// to the client immediately.
111
- //
112
- // Normally, a request will be canceled if the client disconnects
113
- // before the response is received from the backend. If explicitly
114
- // set to -1, client disconnection will be ignored and the request
115
- // will be completed to help facilitate low-latency streaming.
111
FlushInterval caddy.Duration `json:"flush_interval,omitempty"`
112
113
// A list of IP ranges (supports CIDR notation) from which
@@ -833,15 +828,6 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
828
}
829
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
830
836
- // if FlushInterval is explicitly configured to -1 (i.e. flush continuously to achieve
837
- // low-latency streaming), don't let the transport cancel the request if the client
838
- // disconnects: user probably wants us to finish sending the data to the upstream
839
- // regardless, and we should expect client disconnection in low-latency streaming
840
- // scenarios (see issue #4922)
841
- if h.FlushInterval == -1 {
842
- req = req.WithContext(context.WithoutCancel(req.Context()))
843
- }
844
-
831
// do the round-trip
832
start := time.Now()
833
res, err := h.Transport.RoundTrip(req)