From 44ebb0d41c1608dce70a413a465221a8f506a3f4 Mon Sep 17 00:00:00 2001 From: Julien Salleyron Date: Fri, 27 Sep 2024 13:35:57 +0200 Subject: [PATCH] review. --- gzhttp/compress.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gzhttp/compress.go b/gzhttp/compress.go index 318be06ee..d6db1fcca 100644 --- a/gzhttp/compress.go +++ b/gzhttp/compress.go @@ -349,12 +349,12 @@ func (w *GzipResponseWriter) Close() error { ce = w.Header().Get(contentEncoding) cr = w.Header().Get(contentRange) ) - if ct == "" && bodyAllowedForStatus(w.code) { + if ct == "" { ct = http.DetectContentType(w.buf) // Handles the intended case of setting a nil Content-Type (as for http/server or http/fs) // Set the header only if the key does not exist - if _, ok := w.Header()[contentType]; w.setContentType && !ok { + if _, ok := w.Header()[contentType]; !bodyAllowedForStatus(w.code) && w.setContentType && !ok { w.Header().Set(contentType, ct) } }