]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: decompression: test a large decompressed Content-Length response
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 17 Nov 2026 14:38:01 +0000 (15:38 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 17 Nov 2026 14:49:43 +0000 (15:49 +0100)
This test sends a small gzip-compressed body with a Content-Length header,
decompressing into more than a buffer, and checks that the whole
decompressed body is received. It is used to validate the previous fix.

reg-tests/decompression/http_large_cl.vtc [new file with mode: 0644]

diff --git a/reg-tests/decompression/http_large_cl.vtc b/reg-tests/decompression/http_large_cl.vtc
new file mode 100644 (file)
index 0000000..44814f4
--- /dev/null
@@ -0,0 +1,41 @@
+varnishtest "HTTP decompression of a Content-Length response growing beyond a buffer"
+
+feature cmd "$HAPROXY_PROGRAM -cc 'feature(SLZ)'"
+feature cmd "command -v gzip"
+
+feature ignore_unknown_macro
+
+# The whole compressed body is received at once and carries the end of the
+# message, but it decompresses into more than a buffer. The end of message
+# must only be reported once all the decompressed data were emitted.
+shell {
+    yes "decompressed by haproxy" | head -c 24000 | gzip -c > ${tmpdir}/big.gz
+}
+
+server s1 {
+       rxreq
+       txresp -hdr "Content-Encoding: gzip" -bodyfrom ${tmpdir}/big.gz
+} -start
+
+haproxy h1 -conf {
+    defaults
+       mode http
+       timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+       timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+       timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+    listen res
+       bind "fd@${res}"
+       decompression algo-res gzip
+       decompression mode-res always
+       filter decomp-res
+       server s1 ${s1_addr}:${s1_port}
+} -start
+
+client c1 -connect ${h1_res_sock} {
+       txreq -url "/"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.content-encoding == "<undef>"
+       expect resp.bodylen == 24000
+} -run