Skip to content

Commit e14a053

Browse files
committed
feat(serverCompress): skip compressing if client request for identity explicitly
1 parent 32c1155 commit e14a053

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/serverCompress/writer.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
"net/http"
99
)
1010

11+
const contentIdentity = "identity"
1112
const contentEncGzip = "gzip"
1213
const contentEncDeflate = "deflate"
1314

14-
var encodings = []string{contentEncGzip, contentEncDeflate}
15+
var encodings = []string{contentIdentity, contentEncGzip, contentEncDeflate}
1516

1617
func GetWriter(w http.ResponseWriter, r *http.Request) (wc io.WriteCloser, ok bool) {
1718
header := w.Header()
@@ -26,8 +27,8 @@ func GetWriter(w http.ResponseWriter, r *http.Request) (wc io.WriteCloser, ok bo
2627
}
2728

2829
accepts := acceptHeaders.ParseAccepts(r.Header.Get("Accept-Encoding"))
29-
_, encoding, hasSupportedEncoding := accepts.GetPreferredValue(encodings)
30-
if !hasSupportedEncoding {
30+
index, encoding, _ := accepts.GetPreferredValue(encodings)
31+
if index < 1 {
3132
return nil, false
3233
}
3334

0 commit comments

Comments
 (0)