3 releases

0.1.2 Apr 19, 2022
0.1.1 Feb 15, 2022
0.1.0 Feb 15, 2022

#22 in #response-headers

Download history 614/week @ 2024-02-03 1234/week @ 2024-02-10 1696/week @ 2024-02-17 1516/week @ 2024-02-24 1613/week @ 2024-03-02 1558/week @ 2024-03-09 1820/week @ 2024-03-16 2400/week @ 2024-03-23 3531/week @ 2024-03-30 2176/week @ 2024-04-06 2368/week @ 2024-04-13 2806/week @ 2024-04-20 2484/week @ 2024-04-27 2682/week @ 2024-05-04 2683/week @ 2024-05-11 2775/week @ 2024-05-18

11,041 downloads per month
Used in 3 crates (via async_http_range_reader)

MIT/Apache

15KB
271 lines

http-content-range

Build Cr   ates.io Documentation

Tiny Rust lib to decode Content-Range response headers.

extern crate http_content_range;

use http_content_range::ContentRange;

fn main() {
    let content_range_str = "bytes 42-69/420";

    match ContentRange::parse(content_range_str) {
        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
            )
        }
        ContentRange::Unknown => {
            println!("Unable to parse")
        }
    };
}

No runtime deps