accept-encoding

Crates.ioaccept-encoding
lib.rsaccept-encoding
version0.2.0-alpha.2
sourcesrc
created_at2018-11-11 16:19:52.723201
updated_at2019-05-14 18:59:39.929974
descriptionDetermine the best encoding possible from an Accept-Encoding HTTP header.
homepage
repositoryhttps://github.com/rust-net-web/accept-encoding
max_upload_size
id96075
size38,236
maintainers (github:rustasync:maintainers)

documentation

https://docs.rs/accept-encoding

README

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

Commit count: 15

cargo fmt