Skip to main content

Crate web_faith_encoding

Crate web_faith_encoding 

Source
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§

AcceptEncoding
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-Encoding Faith 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§

ByteStream
A body byte-stream, as the decoders take and return one.
RequestStream
A request body stream, as reqwest takes one.