From 71a1e137e9f1222d81add53624ea09647fd7c462 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..7b697dd87 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) } }