Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 15:45 UTC
chore: encode: use FlushError instead of Flush (#6168)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
WeidiDeng committed
Mar 11, 2024 at 11:04 UTC
1bd598e90c9beea54a7e5082bdecff1500752bf1
1 file changed
+5
-5
modules/caddyhttp/encode/encode.go
+5
-5
@@ -232,18 +232,18 @@ func (enc *Encode) Match(rw *responseWriter) bool {
232
return enc.Matcher.Match(rw.statusCode, rw.Header())
233
}
234
235
-// Flush implements http.Flusher. It delays the actual Flush of the underlying ResponseWriterWrapper
236
-// until headers were written.
237
-func (rw *responseWriter) Flush() {
235
+// FlushError is an alternative Flush returning an error. It delays the actual Flush of the underlying
236
+// ResponseWriterWrapper until headers were written.
237
+func (rw *responseWriter) FlushError() error {
238
if !rw.wroteHeader {
239
// flushing the underlying ResponseWriter will write header and status code,
240
// but we need to delay that until we can determine if we must encode and
241
// therefore add the Content-Encoding header; this happens in the first call
242
// to rw.Write (see bug in #4314)
243
- return
243
+ return nil
244
}
245
//nolint:bodyclose
246
- http.NewResponseController(rw.ResponseWriter).Flush()
246
+ return http.NewResponseController(rw.ResponseWriter).Flush()
247
}
248
249
// Write writes to the response. If the response qualifies,