fly-accept-encoding

Crates.iofly-accept-encoding
lib.rsfly-accept-encoding
version0.2.0
sourcesrc
created_at2020-07-02 12:31:23.884835
updated_at2022-05-18 13:45:37.993321
descriptionDetermine the best encoding possible from an Accept-Encoding HTTP header.
homepage
repositoryhttps://github.com/superfly/accept-encoding
max_upload_size
id260616
size9,131
Jerome Gravel-Niquet (jeromegn)

documentation

https://docs.rs/fly-accept-encoding

README

fly-accept-encoding

crates.io version build status downloads docs.rs docs

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

Note: this is a fork of https://github.com/http-rs/accept-encoding with a few more features.

Examples

Basic usage

use fly_accept_encoding::Encoding;
use anyhow::Error;
use http::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};

fn main () -> Result<(), Error> {
  let mut headers = HeaderMap::new();
  headers.insert(ACCEPT_ENCODING, HeaderValue::from_str("gzip, deflate, br")?);

  let encoding = fly_accept_encoding::parse(&headers)?;
  assert_eq!(encoding, Some(Encoding::Gzip));
  Ok(())
}

Installation

$ cargo add fly-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: 28

cargo fmt