6 releases

0.2.0 Oct 9, 2024
0.1.4 Oct 9, 2024
0.1.2 Apr 19, 2022
0.1.1 Feb 15, 2022

#837 in Network programming

Download history 3997/week @ 2024-08-23 4085/week @ 2024-08-30 3298/week @ 2024-09-06 2884/week @ 2024-09-13 3290/week @ 2024-09-20 3659/week @ 2024-09-27 3971/week @ 2024-10-04 3155/week @ 2024-10-11 3150/week @ 2024-10-18 3234/week @ 2024-10-25 2761/week @ 2024-11-01 2885/week @ 2024-11-08 3038/week @ 2024-11-15 2437/week @ 2024-11-22 3070/week @ 2024-11-29 2726/week @ 2024-12-06

11,802 downloads per month
Used in 5 crates (via async_http_range_reader)

MIT/Apache

14KB
207 lines

http-content-range

GitHub crates.io version docs.rs docs crates.io version CI build

Tiny Rust lib to decode Content-Range response headers.

use http_content_range::ContentRange;

let content_range_str = "bytes 42-69/420";

match ContentRange::parse(content_range_str).expect("Failed to parse Content-Range") {
  ContentRange::Bytes(r) => println!(
    "First_byte={}, last_byte={}, complete_length={}",
    r.first_byte, r.last_byte, r.complete_length,
  ),
  ContentRange::UnboundBytes(r) => println!(
    "First_byte={}, last_byte={}, complete_length is unknown",
    r.first_byte, r.last_byte
  ),
  ContentRange::Unsatisfied(r) => println!(
    "Unsatisfied response, complete_length={}",
    r.complete_length
  ),
};

Development

  • This project is easier to develop with just, a modern alternative to make. Install it with cargo install just.
  • To get a list of available commands, run just.
  • To run tests, use just test.

Credits

The code was inspired by the rust-http-range crate.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps