检查是否压缩的时候,如果content-type为空,则默认为text/html

This commit is contained in:
GoEdgeLab
2022-02-15 18:31:37 +08:00
parent b2ba42c1a8
commit 1f12667e65

View File

@@ -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
}