Crate fly_accept_encoding

Source
Expand description

§Examples

use fly_accept_encoding::{Encoding,Error};
use http::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};

let mut headers = HeaderMap::new();
headers.insert(ACCEPT_ENCODING, HeaderValue::from_str("gzip, deflate, br").unwrap());

let encoding = fly_accept_encoding::parse(&headers)?;
assert_eq!(encoding, Some(Encoding::Gzip));
use fly_accept_encoding::{Encoding,Error};
use http::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};

let mut headers = HeaderMap::new();
headers.insert(ACCEPT_ENCODING, HeaderValue::from_str("gzip;q=0.5, deflate;q=0.9, br;q=1.0").unwrap());

let encoding = fly_accept_encoding::parse(&headers)?;
assert_eq!(encoding, Some(Encoding::Brotli));

Enums§

Encoding
Encodings to use.
Error
A list enumerating the categories of errors in this crate.

Functions§

encodings
Parse a set of HTTP headers into a vector containing tuples of options containing encodings and their corresponding q-values.
encodings_iter
Parse a set of HTTP headers into an iterator containing tuples of options containing encodings and their corresponding q-values.
parse
Parse a set of HTTP headers into a single option yielding an Encoding that the client prefers.
preferred
Select the encoding with the largest qval or the first with qval ~= 1

Type Aliases§

Result
A specialized Result type for this crate’s operations.