[Privoxy-devel] [PATCH] Decode zlib-wrapped HTTP deflate responses
William B
williamjamesburke at gmail.com
Sun Nov 22 16:15:08 CET 2026
Hello Privoxy developers,
On master at `08593d41`, I found that a text filter worked on a raw
DEFLATE response but left the same text untouched when the origin used
the zlib wrapper specified for HTTP `Content-Encoding: deflate`. The
attached patch updates `decompress_iob()` and includes a small
loopback regression test. [RFC 9110
§8.4.1.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.4.1.2)
Thanks to Wil Mahan for the original gzip and zlib decompression
patch. His patch already described the difference between the
specified wrapper and the raw streams seen in practice. This change
builds on that work. [Privoxy patch
#65](https://sourceforge.net/p/ijbswa/patches/65/)
The proposed rule gives a syntactically valid zlib header precedence.
Once selected, wrapped decoding must finish, validate the Adler-32
checksum and consume the entire body. Other prefixes take the legacy
raw path. A valid raw stream can share those first two bytes. If
wrapped decoding then fails, Privoxy follows its existing behavior and
forwards the original coded body without applying the filter. Would
you be comfortable with this precedence rule?
The patch also restores the legacy raw inflater's zero lookahead byte
after chunked transfer framing has been removed. The logical body
length stays the same.
I tested the patch on a native Linux build with zlib 1.3. All eight
cases passed. On the unmodified commit, ordinary wrapped deflate, a
smaller-window wrapper and both short-body cases failed their filter
assertions. Raw deflate with both Content-Length and chunked framing,
gzip and passthrough for an unsupported preset dictionary behaved as
expected on both builds.
After applying the patch and building Privoxy with zlib support, run
`python3 tests/http-deflate.py ./privoxy`. The script starts a
loopback origin and proxy with temporary configuration. Python's
`unittest` reports `Ran 1 test` because it counts test methods. This
method checks eight response cases as subtests. If all eight pass, the
run ends with `OK`.
Attachment: `http-deflate.patch`
More information about the Privoxy-devel
mailing list