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, 15:45 UTC
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 <mholt@users.noreply.github.com>
WeidiDeng committed
Mar 12, 2024 at 04:03 UTC
c93e30454ffcdc135a2fe762c0b1509b8c7f7f14
1 file changed
+10
modules/caddyhttp/responsewriter.go
+10
@@ -230,6 +230,16 @@ func (rr *responseRecorder) WriteResponse() error {
230
return err
231
}
232
233
+// FlushError will suppress actual flushing if the response is buffered. See:
234
+// https://github.com/caddyserver/caddy/issues/6144
235
+func (rr *responseRecorder) FlushError() error {
236
+ if rr.stream {
237
+ //nolint:bodyclose
238
+ return http.NewResponseController(rr.ResponseWriterWrapper).Flush()
239
+ }
240
+ return nil
241
+}
242
+
243
func (rr *responseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
244
//nolint:bodyclose
245
conn, brw, err := http.NewResponseController(rr.ResponseWriterWrapper).Hijack()