diff options
author | WeidiDeng <[email protected]> | 2024-03-12 04:03:20 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-11 20:03:20 +0000 |
commit | c93e30454ffcdc135a2fe762c0b1509b8c7f7f14 (patch) | |
tree | 11e757c0b2371766af65f17b405bb9ec77e98dfa | |
parent | 1bd598e90c9beea54a7e5082bdecff1500752bf1 (diff) | |
download | caddy-c93e30454ffcdc135a2fe762c0b1509b8c7f7f14.tar.gz caddy-c93e30454ffcdc135a2fe762c0b1509b8c7f7f14.zip |
caddyhttp: suppress flushing if the response is being buffered (#6150)
* suppress flushing if the response is being buffered
* fix lint
---------
Co-authored-by: Matt Holt <[email protected]>
-rw-r--r-- | modules/caddyhttp/responsewriter.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/caddyhttp/responsewriter.go b/modules/caddyhttp/responsewriter.go index 37c264634..51f672eee 100644 --- a/modules/caddyhttp/responsewriter.go +++ b/modules/caddyhttp/responsewriter.go @@ -230,6 +230,16 @@ func (rr *responseRecorder) WriteResponse() error { return err } +// FlushError will suppress actual flushing if the response is buffered. See: +// https://github.com/caddyserver/caddy/issues/6144 +func (rr *responseRecorder) FlushError() error { + if rr.stream { + //nolint:bodyclose + return http.NewResponseController(rr.ResponseWriterWrapper).Flush() + } + return nil +} + func (rr *responseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) { //nolint:bodyclose conn, brw, err := http.NewResponseController(rr.ResponseWriterWrapper).Hijack() |