diff options
author | WeidiDeng <[email protected]> | 2024-03-11 11:04:35 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-10 23:04:35 -0400 |
commit | 1bd598e90c9beea54a7e5082bdecff1500752bf1 (patch) | |
tree | 44db8a99e1816ac08e7d92c436fba0453420d846 | |
parent | e698ec5139e94de4702ebd7530546e16393638b9 (diff) | |
download | caddy-1bd598e90c9beea54a7e5082bdecff1500752bf1.tar.gz caddy-1bd598e90c9beea54a7e5082bdecff1500752bf1.zip |
chore: encode: use FlushError instead of Flush (#6168)
Co-authored-by: Francis Lavoie <[email protected]>
-rw-r--r-- | modules/caddyhttp/encode/encode.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/caddyhttp/encode/encode.go b/modules/caddyhttp/encode/encode.go index 91f25294f..7d5f556f1 100644 --- a/modules/caddyhttp/encode/encode.go +++ b/modules/caddyhttp/encode/encode.go @@ -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, |