当压缩格式不在Accept-Encoding中时自动解压

This commit is contained in:
GoEdgeLab
2022-02-18 11:05:09 +08:00
parent 5a91dbe34e
commit d605d8dc12
2 changed files with 19 additions and 22 deletions

View File

@@ -5,7 +5,6 @@ import (
"errors"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/TeaOSLab/EdgeNode/internal/compressions"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"github.com/TeaOSLab/EdgeNode/internal/utils"
"io"
@@ -262,24 +261,6 @@ func (this *HTTPRequest) doReverseProxy() {
}
}
// 解压
if !resp.Uncompressed {
var contentEncoding = resp.Header.Get("Content-Encoding")
if len(contentEncoding) > 0 && !httpAcceptEncoding(this.RawReq.Header.Get("Accept-Encoding"), contentEncoding) {
reader, err := compressions.NewReader(resp.Body, contentEncoding)
if err == nil {
var body = resp.Body
defer func() {
_ = body.Close()
}()
resp.Body = reader
resp.Header.Del("Content-Encoding")
resp.Header.Del("Content-Length")
}
}
}
// 响应Header
this.writer.AddHeaders(resp.Header)
this.processResponseHeaders(resp.StatusCode)