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>
This commit is contained in:
WeidiDeng 2024-03-12 04:03:20 +08:00 committed by GitHub
parent 1bd598e90c
commit c93e30454f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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()