mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-15 07:06:36 +08:00
内容压缩支持对已压缩内容重新压缩
This commit is contained in:
@@ -444,7 +444,8 @@ func (this *HTTPWriter) PrepareCompression(size int64) {
|
||||
}
|
||||
|
||||
// 如果已经有编码则不处理
|
||||
if len(this.writer.Header().Get("Content-Encoding")) > 0 {
|
||||
var contentEncoding = this.writer.Header().Get("Content-Encoding")
|
||||
if len(contentEncoding) > 0 && (!this.compressionConfig.DecompressData || !lists.ContainsString([]string{"gzip", "deflate", "br"}, contentEncoding)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -458,6 +459,12 @@ func (this *HTTPWriter) PrepareCompression(size int64) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// 压缩前后如果编码一致,则不处理
|
||||
if compressionEncoding == contentEncoding {
|
||||
return
|
||||
}
|
||||
|
||||
this.compressionType = compressionType
|
||||
|
||||
// compression writer
|
||||
@@ -468,6 +475,15 @@ func (this *HTTPWriter) PrepareCompression(size int64) {
|
||||
return
|
||||
}
|
||||
|
||||
// convert between encodings
|
||||
if len(contentEncoding) > 0 {
|
||||
this.compressionWriter, err = compressions.NewEncodingWriter(contentEncoding, this.compressionWriter)
|
||||
if err != nil {
|
||||
remotelogs.Error("HTTP_WRITER", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// body copy
|
||||
if this.bodyCopying {
|
||||
this.compressionBodyBuffer = bytes.NewBuffer([]byte{})
|
||||
|
||||
Reference in New Issue
Block a user