https://github.com/nyurik/http-content-range
Tiny Rust lib to decode Content-Range response header
https://github.com/nyurik/http-content-range
Last synced: 18 days ago
JSON representation
Tiny Rust lib to decode Content-Range response header
- Host: GitHub
- URL: https://github.com/nyurik/http-content-range
- Owner: nyurik
- License: apache-2.0
- Created: 2022-02-14T21:41:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-16T06:29:36.000Z (about 1 month ago)
- Last Synced: 2025-03-25T09:12:18.091Z (about 1 month ago)
- Language: Rust
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# http-content-range
[](https://github.com/nyurik/http-content-range)
[](https://crates.io/crates/http-content-range)
[](https://docs.rs/http-content-range)
[](https://github.com/nyurik/http-content-range/blob/main/LICENSE-APACHE)
[](https://github.com/nyurik/http-content-range/actions)
[](https://app.codecov.io/gh/nyurik/http-content-range)Tiny Rust lib to decode Content-Range response headers.
```rust
use http_content_range::ContentRange;let value = ContentRange::parse("bytes 42-69/420");
match value.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](https://github.com/casey/just#readme), 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](https://github.com/bancek/rust-http-range) crate.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license ([LICENSE-MIT](LICENSE-MIT) or )
at your option.### 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.