Skip to content

Commit dfefce7

Browse files
committed
Add test for custom compression encodings that we should not error on
1 parent a060c50 commit dfefce7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

js/modules/k6/http/request_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,22 @@ func TestRequestAndBatch(t *testing.T) {
354354
`))
355355
assert.NoError(t, err)
356356
})
357+
t.Run("custom compression", func(t *testing.T) {
358+
// We should not try to decode it
359+
tb.Mux.HandleFunc("/customcompression", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
360+
w.Header().Set("Content-Encoding", "custom")
361+
_, err := w.Write([]byte(`{"custom": true}`))
362+
assert.NoError(t, err)
363+
}))
364+
365+
_, err := common.RunString(rt, sr(`
366+
let res = http.get("HTTPBIN_URL/customcompression");
367+
if (res.json()["custom"] != true) {
368+
throw new Error("unexpected body data: " + res.body)
369+
}
370+
`))
371+
assert.NoError(t, err)
372+
})
357373
})
358374
t.Run("CompressionWithAcceptEncodingHeader", func(t *testing.T) {
359375
t.Run("gzip", func(t *testing.T) {

0 commit comments

Comments
 (0)