#accept-encoding #gzip #brotli #http #server

accept-encoding-fork

Determine the best encoding possible from an Accept-Encoding HTTP header

1 unstable release

0.2.0-alpha.3 Feb 3, 2020

#11 in #brotli

Download history 68/week @ 2020-08-01 19/week @ 2020-08-08 23/week @ 2020-08-15 17/week @ 2020-08-22 18/week @ 2020-08-29 21/week @ 2020-09-05 17/week @ 2020-09-12 16/week @ 2020-09-19 16/week @ 2020-09-26 19/week @ 2020-10-03 12/week @ 2020-10-10 3/week @ 2020-10-17 2/week @ 2020-10-24 4/week @ 2020-10-31 4/week @ 2020-11-07 4/week @ 2020-11-14

123 downloads per month

MIT/Apache

14KB
134 lines

accept-encoding

crates.io version build status downloads docs.rs docs

Determine the best encoding possible from an Accept-Encoding HTTP header.

Examples

Basic usage

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

fn main () -> Result<(), failure::Error> {
  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));
  Ok(())
}

Installation

$ cargo add accept-encoding

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

References

None.

License

MIT OR Apache-2.0

Dependencies

~640KB
~10K SLoC