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

accept-encoding

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

3 unstable releases

✓ Uses Rust 2018 edition

0.2.0-alpha.2 May 14, 2019
0.1.0 Nov 11, 2018

#54 in HTTP server

Download history 4/week @ 2019-03-21 4/week @ 2019-03-28 2/week @ 2019-04-04 2/week @ 2019-04-11 4/week @ 2019-04-25 3/week @ 2019-05-02 49/week @ 2019-05-09 124/week @ 2019-05-16 44/week @ 2019-05-23 8/week @ 2019-05-30 21/week @ 2019-06-06 42/week @ 2019-06-13 29/week @ 2019-06-20 31/week @ 2019-06-27

82 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

~2.5MB
~44K SLoC