@marcel91200 / caddy Mirror · read-only / commits / 976469ca
Fork 0

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, 09:30 UTC

encode: flush already compressed data from the encoder (#6471)

WeidiDeng committed Jul 28, 2024 at 07:46 UTC 976469ca0dbbbd948dbfd6a4caedb1e7c914ef3d
1 file changed +9
modules/caddyhttp/encode/encode.go
+9
@@ -266,6 +266,14 @@ func (rw *responseWriter) FlushError() error {
266 // to rw.Write (see bug in #4314)
267 return nil
268 }
269 + // also flushes the encoder, if any
270 + // see: https://github.com/jjiang-stripe/caddy-slow-gzip
271 + if rw.w != nil {
272 + err := rw.w.Flush()
273 + if err != nil {
274 + return err
275 + }
276 + }
277 //nolint:bodyclose
278 return http.NewResponseController(rw.ResponseWriter).Flush()
279 }
@@ -475,6 +483,7 @@ type encodingPreference struct {
483 type Encoder interface {
484 io.WriteCloser
485 Reset(io.Writer)
486 + Flush() error // encoder by default buffers data to maximize compressing rate
487 }
488
489 // Encoding is a type which can create encoders of its kind