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

Encodings to use.

A list enumerating the categories of errors in this crate.

Functions

Parse a set of HTTP headers into a vector containing tuples of options containing encodings and their corresponding q-values.

Parse a set of HTTP headers into an iterator containing tuples of options containing encodings and their corresponding q-values.

Parse a set of HTTP headers into a single option yielding an Encoding that the client prefers.

Select the encoding with the largest qval or the first with qval ~= 1

Type Definitions

A specialized Result type for this crate’s operations.