Skip to content

Commit cbf3f83

Browse files
committed
feat: add support for identity compression algorithm in confighttp
1 parent 52e6bf4 commit cbf3f83

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

config/confighttp/compression.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ var availableDecoders = map[string]func(body io.ReadCloser) (io.ReadCloser, erro
6666
// Not a compressed payload. Nothing to do.
6767
return nil, nil
6868
},
69+
"identity": func(io.ReadCloser) (io.ReadCloser, error) {
70+
// Per RFC 7231 §3.1.2.2, "identity" means no encoding.
71+
return nil, nil
72+
},
6973
"gzip": func(body io.ReadCloser) (io.ReadCloser, error) {
7074
gr, err := gzip.NewReader(body)
7175
if err != nil {
@@ -249,6 +253,9 @@ func httpContentDecompressor(h http.Handler, maxRequestBodySize int64, eh func(w
249253
for _, dec := range enableDecoders {
250254
enabled[dec] = availableDecoders[dec]
251255

256+
if dec == "" {
257+
enabled["identity"] = availableDecoders["identity"]
258+
}
252259
if dec == "deflate" {
253260
enabled["deflate"] = availableDecoders["zlib"]
254261
}

config/confighttp/compression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func TestCompressionAlgorithmsEdgeCases(t *testing.T) {
638638
compressionAlgorithms: []string{"", "gzip", "zstd"},
639639
contentEncoding: "identity",
640640
body: testBody,
641-
wantStatus: http.StatusBadRequest, // BUG: should be http.StatusOK
641+
wantStatus: http.StatusOK, // BUG: should be http.StatusOK
642642
},
643643
{
644644
name: "Mixed_Snappy_Rejected",

0 commit comments

Comments
 (0)