@marcel91200 / caddy Mirror · read-only / commits / f70a7578
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

reverseproxy: Remove redundant flushing (#4299)

From reading through the code, I think this code path is now obsoleted by the changes made in https://github.com/caddyserver/caddy/pull/4266. Basically, `h.flushInterval()` will set the flush interval to `-1` if we're in a bi-directional stream, and the recent PR ensured that `h.copyResponse()` properly flushes headers immediately when the flush interval is non-zero. So now there should be no need to call Flush before calling `h.copyResponse()`.

Francis Lavoie committed Aug 23, 2021 at 13:54 UTC f70a7578faa1ab9169bc05a121911bf33d7d3da3
1 file changed -9
modules/caddyhttp/reverseproxy/reverseproxy.go
-9
@@ -691,15 +691,6 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, repl *
691 }
692
693 rw.WriteHeader(res.StatusCode)
694 -
695 - // some apps need the response headers before starting to stream content with http2,
696 - // so it's important to explicitly flush the headers to the client before streaming the data.
697 - // (see https://github.com/caddyserver/caddy/issues/3556 for use case and nuances)
698 - if h.isBidirectionalStream(req, res) {
699 - if wf, ok := rw.(http.Flusher); ok {
700 - wf.Flush()
701 - }
702 - }
694 err = h.copyResponse(rw, res.Body, h.flushInterval(req, res))
695 res.Body.Close() // close now, instead of defer, to populate res.Trailer
696 if err != nil {