compression
ModuleResponse compression: choosing an algorithm from the client's
Accept-Encoding header, and compressing bodies with it.
The algorithms and the negotiation are utopia-compression's; this
module adds what Response::send() decides on top: the levels, and which
content types are compressed.
Contents
use utopia_http::Compression;pub struct CompressionResponse compression settings of an application.
Default.use utopia_http::Algorithm;pub enum AlgorithmA compression algorithm a response can be encoded with.
use utopia_http::compression::compressible;pub fn compressible(content_type: &str) -> boolWhether responses of a content type are compressed: text, scripts, JSON, XML, fonts, SVG and similar. Parameters are ignored and the match is case-insensitive.
use utopia_http::compression::from_accept_encoding;pub fn from_accept_encoding(accept: &str, supported: &[String]) -> Option<Algorithm>The algorithm to compress with for an Accept-Encoding header: the
accepted one with the highest q (header order on ties) among
supported (every algorithm when empty).
none and identity can win, and mean no compression; None is also
returned when nothing supported is accepted.