From 1f12667e650b435892432d0e220c55f6ebe642b8 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 15 Feb 2022 18:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E6=98=AF=E5=90=A6=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?content-type=E4=B8=BA=E7=A9=BA=EF=BC=8C=E5=88=99=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=BAtext/html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_writer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index a38dac7..3c31bda 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -339,7 +339,12 @@ func (this *HTTPWriter) PrepareCompression(resp *http.Response, size int64) { } // 尺寸和类型 - if !this.compressionConfig.MatchResponse(this.Header().Get("Content-Type"), size, filepath.Ext(this.req.Path()), this.req.Format) { + var contentType = this.Header().Get("Content-Type") + if len(contentType) == 0 { + // 如果没有显式设置Content-Type,我们就认为是 text/html + contentType = "text/html" + } + if !this.compressionConfig.MatchResponse(contentType, size, filepath.Ext(this.req.Path()), this.req.Format) { return }