Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
CAFxX committed Jan 29, 2021
1 parent df607f4 commit b6a62f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,13 @@ func (w *compressWriter) Flush() {
return
}

// Flush the compressor, if supported,
// note: http.ResponseWriter does not implement Flusher, so we need to call ResponseWriter.Flush anyway.
// Flush the compressor, if supported.
// note: http.ResponseWriter does not implement Flusher (http.Flusher does not return an error),
// so we need to later call ResponseWriter.Flush anyway:
// - in case we are bypassing compression, w.w is the parent ResponseWriter, and therefore we skip
// this as the parent ResponseWriter does not implement Flusher.
// - in case we are NOT bypassing compression, w.w is the compressor, and therefore we flush the
// compressor and then we flush the parent ResponseWriter.
if fw, ok := w.w.(Flusher); ok {
_ = fw.Flush()
}
Expand Down

0 comments on commit b6a62f1

Please sign in to comment.