[−][src]Function fly_accept_encoding::encodings
pub fn encodings(headers: &HeaderMap) -> Result<Vec<(Option<Encoding>, f32)>>
Parse a set of HTTP headers into a vector containing tuples of options containing encodings and their corresponding q-values.
If you're looking for more fine-grained control over what encoding to choose for the client, or if you don't support every Encoding
listed, this is likely what you want.
Note that a result of None
indicates there preference is expressed on which encoding to use.
Either the Accept-Encoding
header is not present, or *
is set as the most preferred encoding.
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("zstd;q=1.0, deflate;q=0.8, br;q=0.9").unwrap()); let encodings = fly_accept_encoding::encodings(&headers)?; for (encoding, qval) in encodings { println!("{:?} {}", encoding, qval); }