Skip to main content

Module gzip

Module gzip 

Source
Expand description

The two framings around a DEFLATE stream: gzip (RFC 1952) and zlib (RFC 1950).

Both wrap the same raw stream from deflate.rs; they differ only in the header and which checksum ends them. HTTP names them gzip and — confusingly — deflate: despite the name, Content-Encoding: deflate is the zlib format in practice (RFC 9110 §8.4.1.2 says so, and every browser and server agrees), so the middleware uses zlib_compress and zlib_decompress for it, never the raw stream.

Functions§

compress
Wrap input as a single gzip member.
decompress
Unwrap and inflate gzip data, with output capped at deflate::DEFAULT_MAX_OUTPUT.
decompress_with_limit
Unwrap and inflate gzip data, refusing to produce more than max_out bytes in total.
zlib_compress
Wrap input in the zlib format — what HTTP calls deflate.
zlib_decompress
Unwrap and inflate zlib data, with output capped at deflate::DEFAULT_MAX_OUTPUT.
zlib_decompress_with_limit
Unwrap and inflate zlib data, refusing to produce more than max_out bytes. The Adler-32 trailer is verified, and a stream that asks for a preset dictionary (FDICT) is rejected: nothing in HTTP defines one.