Skip to content

Commit

Permalink
caddyhttp: suppress flushing if the response is being buffered (#6150)
Browse files Browse the repository at this point in the history
* suppress flushing if the response is being buffered

* fix lint

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
  • Loading branch information
WeidiDeng and mholt committed Mar 11, 2024
1 parent 1bd598e commit c93e304
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/caddyhttp/responsewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c93e304

Please sign in to comment.