Skip to main content

Module compression

Module compression 

Source
Expand description

Response decompression.

Provides streaming decompression of response bodies based on Content-Encoding headers. Supports gzip, deflate, brotli, and zstd via feature-gated async-compression decoders.

§Policy

When automatic decompression is enabled (the default when any compression feature is compiled in), the client:

  1. Advertises supported encodings in Accept-Encoding.
  2. Decodes compressed response bodies transparently.
  3. Strips Content-Encoding and Content-Length from decoded response headers.

If the server responds with an unsupported encoding and automatic decompression is enabled, an Error::UnsupportedContentEncoding is returned. If decompression is disabled, the raw bytes pass through unchanged.

Structs§

DecompressionLimit
Limits applied during response body decompression.

Enums§

ContentCoding
A content coding identifier.

Functions§

accept_encoding_value
Generate the Accept-Encoding header value for the compiled-in features. Returns None if no compression features are enabled.
decompress_buffered
Decompress a fully buffered byte slice using synchronous decoding.
decompress_stream
Wrap a byte stream in decompression decoders based on the Content-Encoding header.
validate_content_encodings
Check whether a Content-Encoding header value contains only supported encodings.