mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
chore: encode: use FlushError instead of Flush (#6168)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
This commit is contained in:
parent
e698ec5139
commit
1bd598e90c
1 changed files with 5 additions and 5 deletions
|
@ -232,18 +232,18 @@ func (enc *Encode) Match(rw *responseWriter) bool {
|
|||
return enc.Matcher.Match(rw.statusCode, rw.Header())
|
||||
}
|
||||
|
||||
// Flush implements http.Flusher. It delays the actual Flush of the underlying ResponseWriterWrapper
|
||||
// until headers were written.
|
||||
func (rw *responseWriter) Flush() {
|
||||
// FlushError is an alternative Flush returning an error. It delays the actual Flush of the underlying
|
||||
// ResponseWriterWrapper until headers were written.
|
||||
func (rw *responseWriter) FlushError() error {
|
||||
if !rw.wroteHeader {
|
||||
// flushing the underlying ResponseWriter will write header and status code,
|
||||
// but we need to delay that until we can determine if we must encode and
|
||||
// therefore add the Content-Encoding header; this happens in the first call
|
||||
// to rw.Write (see bug in #4314)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
//nolint:bodyclose
|
||||
http.NewResponseController(rw.ResponseWriter).Flush()
|
||||
return http.NewResponseController(rw.ResponseWriter).Flush()
|
||||
}
|
||||
|
||||
// Write writes to the response. If the response qualifies,
|
||||
|
|
Loading…
Reference in a new issue