diff --git a/flate/stateless.go b/flate/stateless.go index 544162a431..93a1d15031 100644 --- a/flate/stateless.go +++ b/flate/stateless.go @@ -59,9 +59,9 @@ var bitWriterPool = sync.Pool{ }, } -// StatelessDeflate allows to compress directly to a Writer without retaining state. +// StatelessDeflate allows compressing directly to a Writer without retaining state. // When returning everything will be flushed. -// Up to 8KB of an optional dictionary can be given which is presumed to presumed to precede the block. +// Up to 8KB of an optional dictionary can be given which is presumed to precede the block. // Longer dictionaries will be truncated and will still produce valid output. // Sending nil dictionary is perfectly fine. func StatelessDeflate(out io.Writer, in []byte, eof bool, dict []byte) error { diff --git a/gzhttp/compress.go b/gzhttp/compress.go index 3ec1e799ae..91503436f5 100644 --- a/gzhttp/compress.go +++ b/gzhttp/compress.go @@ -196,12 +196,13 @@ func (w *GzipResponseWriter) startGzip() error { // startPlain writes to sent bytes and buffer the underlying ResponseWriter without gzip. func (w *GzipResponseWriter) startPlain() error { + w.Header().Del(HeaderNoCompression) if w.code != 0 { w.ResponseWriter.WriteHeader(w.code) // Ensure that no other WriteHeader's happen w.code = 0 } - delete(w.Header(), HeaderNoCompression) + w.ignore = true // If Write was never called then don't call Write on the underlying ResponseWriter. if len(w.buf) == 0 {