Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config/confighttp/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ var availableDecoders = map[string]func(body io.ReadCloser) (io.ReadCloser, erro
// Not a compressed payload. Nothing to do.
return nil, nil
},
"identity": func(io.ReadCloser) (io.ReadCloser, error) {
// Per RFC 7231 §3.1.2.2, "identity" means no encoding.
return nil, nil
},
"gzip": func(body io.ReadCloser) (io.ReadCloser, error) {
gr, err := gzip.NewReader(body)
if err != nil {
Expand Down Expand Up @@ -249,6 +253,9 @@ func httpContentDecompressor(h http.Handler, maxRequestBodySize int64, eh func(w
for _, dec := range enableDecoders {
enabled[dec] = availableDecoders[dec]

if dec == "" {
enabled["identity"] = availableDecoders["identity"]
}
if dec == "deflate" {
enabled["deflate"] = availableDecoders["zlib"]
}
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func TestCompressionAlgorithmsEdgeCases(t *testing.T) {
compressionAlgorithms: []string{"", "gzip", "zstd"},
contentEncoding: "identity",
body: testBody,
wantStatus: http.StatusBadRequest, // BUG: should be http.StatusOK
wantStatus: http.StatusOK, // BUG: should be http.StatusOK
},
{
name: "Mixed_Snappy_Rejected",
Expand Down