From b754b5f9acd330a2ea9007d2cb2e252f6abe7868 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Tue, 12 Sep 2023 21:22:08 +0200 Subject: [PATCH] fix flushing of transparently compressed gzip output this is a problem for connections like SSE, that only send data on events. those events would stay in the gzip buffer until lots more data was written. bug because of automatically typing "if err != nil"... found while testing the maildir/mbox web-based import while working on message threading support. the import gets progress SSE events that were now hanging. --- http/web.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/web.go b/http/web.go index 23e98f2..c1ceaef 100644 --- a/http/web.go +++ b/http/web.go @@ -140,7 +140,7 @@ func (w *loggingWriter) Write(buf []byte) (int, error) { // issues due to buffering. // w.Gzip.Write updates w.Size with the compressed byte count. n, err = w.Gzip.Write(buf) - if err != nil { + if err == nil { err = w.Gzip.Flush() } if n > 0 {