Expand description
HTTP content coding for request and response bodies: gzip, deflate, brotli, and zstd.
An HTTP stack usually decides for itself which codings to advertise and decode. This lets the
caller own that decision instead, so decoding can rest on the Accept-Encoding of the request
actually in hand rather than on whatever the layer beneath negotiated.
On the way back, AcceptEncoding::parse reads what a request advertised and decision says
which coding a response should be decoded under, if any; decode_stream wraps the body in the
decoder for it. On the way out, compress_buffer and compress_stream apply a coding to a
request body, and layer_content_encoding names it alongside whatever the caller had already
declared.
deflate is the zlib-wrapped form of RFC 1950, which is what mainstream clients decode it as.
Structs§
- Accept
Encoding - A parsed
Accept-Encoding, enough to answer whether a coding was accepted.
Enums§
- Coding
- A content coding Faith can decode. Wire tokens:
gzip,deflate,br,zstd.
Constants§
- DEFAULT_
ACCEPT_ ENCODING - The
Accept-EncodingFaith advertises when the caller advertises none.
Functions§
- compress_
buffer - Compress a buffered request body, yielding the bytes that go on the wire.
- compress_
stream - Compress a streaming request body as its chunks arrive.
- decision
- Decide whether and how to decode a response body.
- decode_
stream - Wrap a body byte-stream in a decoder for
coding. - layer_
content_ encoding - Join the codings a request already declares with the one applied on top.
- strip_
decoded_ headers - Strip the headers that describe the encoded bytes, once a body has been decoded.
Type Aliases§
- Byte
Stream - A body byte-stream, as the decoders take and return one.
- Request
Stream - A request body stream, as reqwest takes one.