根据Accept-Encoding决定是否解压响应内容

This commit is contained in:
GoEdgeLab
2021-12-29 10:57:15 +08:00
parent 42710c4e36
commit 67213a1604
8 changed files with 127 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ package compressions
import (
"github.com/andybalholm/brotli"
"io"
"strings"
)
type BrotliReader struct {
@@ -16,7 +17,11 @@ func NewBrotliReader(reader io.Reader) (Reader, error) {
}
func (this *BrotliReader) Read(p []byte) (n int, err error) {
return this.reader.Read(p)
n, err = this.reader.Read(p)
if err != nil && strings.Contains(err.Error(), "excessive") {
err = io.EOF
}
return
}
func (this *BrotliReader) Close() error {