http-content-range

Crates.iohttp-content-range
lib.rshttp-content-range
version0.2.0
sourcesrc
created_at2022-02-15 03:23:09.815094
updated_at2024-10-09 21:14:42.250039
descriptionHTTP Content Range response header parser
homepage
repositoryhttps://github.com/nyurik/http-content-range
max_upload_size
id532510
size25,183
Yuri Astrakhan (nyurik)

documentation

README

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.

Commit count: 12

cargo fmt