Crate accept_encoding_fork

Source
Expand description

§Examples

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

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

let encoding = accept_encoding::parse(&headers)?;
assert_eq!(encoding, Some(Encoding::Gzip));
use accept_encoding::Encoding;
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")?);

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

Structs§

  • A specialized Error type for this crate’s operations.

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 a single option yielding an Encoding that the client prefers.

Type Aliases§

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