From 2dacd7c4f233a27dd827f67ee0e394edfd705254 Mon Sep 17 00:00:00 2001 From: samwaf Date: Wed, 19 Mar 2025 10:41:10 +0800 Subject: [PATCH] fix:response error #IBU1DX --- wafenginecore/wafengine.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wafenginecore/wafengine.go b/wafenginecore/wafengine.go index 6efe57a..697e439 100644 --- a/wafenginecore/wafengine.go +++ b/wafenginecore/wafengine.go @@ -655,16 +655,13 @@ func (waf *WafEngine) modifyResponse() func(*http.Response) error { } } } - //将数据在回写上去 - finalCompressBytes, _ := waf.compressContent(resp, orgContentBytes) - resp.Body = io.NopCloser(bytes.NewBuffer(finalCompressBytes)) - - // head 修改追加内容 - resp.ContentLength = int64(len(finalCompressBytes)) - resp.Header.Set("Content-Length", strconv.FormatInt(int64(len(finalCompressBytes)), 10)) - } } + //将数据在回写上去 + finalCompressBytes, _ := waf.compressContent(resp, orgContentBytes) + resp.Body = io.NopCloser(bytes.NewBuffer(finalCompressBytes)) + resp.ContentLength = int64(len(finalCompressBytes)) + resp.Header.Set("Content-Length", strconv.FormatInt(int64(len(finalCompressBytes)), 10)) } else { resp.Body = io.NopCloser(bytes.NewBuffer(orgContentBytes))