8 stable releases

2.0.0 Jan 11, 2019
1.2.2 Dec 31, 2018
1.2.1 Sep 22, 2018
1.2.0 Jul 7, 2018
1.0.0 May 25, 2017

#511 in Parser implementations

Download history 588/week @ 2023-02-03 428/week @ 2023-02-10 326/week @ 2023-02-17 421/week @ 2023-02-24 422/week @ 2023-03-03 373/week @ 2023-03-10 358/week @ 2023-03-17 299/week @ 2023-03-24 395/week @ 2023-03-31 543/week @ 2023-04-07 260/week @ 2023-04-14 403/week @ 2023-04-21 406/week @ 2023-04-28 428/week @ 2023-05-05 484/week @ 2023-05-12 395/week @ 2023-05-19

1,801 downloads per month
Used in 6 crates (4 directly)

MIT license

10KB
182 lines

accept-language

A tiny library for parsing the Accept-Language header from browsers (as defined here)

Usage

accept-language is intended to be used by a webserver, probably to decide which languages to serve up to the user based on their preferred language and the languages your application supports.

At it's most basic, it looks like this

extern crate accept_language;

use accept_language::{intersection, parse};

let user_languages = parse("en-US, en-GB;q=0.5");
let common_languages = intersection("en-US, en-GB;q=0.5", vec!["en-US", "de", "en-GB"]);

For more info and to view the full documentation, check them out on docs.rs.

Stability

accept-language is fuzz tested with cargo-fuzz. As of 1.2.1, these are the results of both fuzz tests for parse and intersection respectively.

parse

cargo fuzz run -O parse -- -max_total_time=60
...
Done 926619 runs in 61 second(s)

intersection

cargo fuzz run -O intersection -- -max_total_time=60
...
Done 846914 runs in 61 second(s)

Contributing

Contributions are always welcome! If you found a bug, please submit an issue. If you'd like to submit a patch or feature, feel free to submit a pull request. rustfmt should be used to have consistent code formatting throughout the project.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Changelog

License

No runtime deps