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

fly-accept-encoding

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

2 releases

0.2.0 May 18, 2022
0.2.0-alpha.5 Jul 2, 2020

#431 in HTTP server

Download history 2074/week @ 2023-12-10 1729/week @ 2023-12-17 788/week @ 2023-12-24 1110/week @ 2023-12-31 1240/week @ 2024-01-07 1355/week @ 2024-01-14 1315/week @ 2024-01-21 1216/week @ 2024-01-28 856/week @ 2024-02-04 772/week @ 2024-02-11 1235/week @ 2024-02-18 1247/week @ 2024-02-25 1237/week @ 2024-03-03 891/week @ 2024-03-10 1107/week @ 2024-03-17 1037/week @ 2024-03-24

4,382 downloads per month
Used in 22 crates (2 directly)

MIT/Apache

10KB
96 lines

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

Dependencies

~1.1–1.8MB
~35K SLoC