]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: flt-decomp: skip responses without a transfer length
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 2 Dec 2026 14:28:49 +0000 (15:28 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 2 Dec 2026 14:33:02 +0000 (15:33 +0100)
When a compressed response has neither a content-length nor a chunked
encoding, its end is only known when the server closes. In this case,
http_response_forward_body() ends the message as soon as the close is
reported and the filter is not called anymore, so the decompressed data
it could not emit yet were lost. The response was silently truncated,
e.g. 998006 bytes delivered out of 1MB, with nothing reported to the
client nor in the logs.

Let's not decompress such messages, like the compression filter already
does. They are forwarded untouched, with their content-encoding header,
including in "always" mode. The filter was introduced in 3.5-dev6, so no
backport is needed.

src/flt_decomp.c

index 5603f615599c28da40f7a32318ed5d80e33dbb5f..3fe8d51b8e245e4ebb91898a8f94a5c5083e30b7 100644 (file)
@@ -496,6 +496,10 @@ static int decomp_strm_http_headers(struct stream *s, struct filter *f, struct h
        if (msg->flags & HTTP_MSGF_BODYLESS)
                goto no_decomp;
 
+       /* the end of the payload is unknown without a transfer length */
+       if (!(msg->flags & HTTP_MSGF_XFER_LEN))
+               goto no_decomp;
+
        if (msg->chn->flags & CF_ISRESP) {
                struct http_txn *txn = s->txn.http;