Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response.content_range() API #1468

Open
nyurik opened this issue Feb 14, 2022 · 0 comments
Open

Add response.content_range() API #1468

nyurik opened this issue Feb 14, 2022 · 0 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented Feb 14, 2022

When working with content ranges, all clients would need to perform the same content range parsing based on RFC. Would it be ok to add support for such parsing to the reqwest lib? I could try to provide a PR for that if there is interest.

Update I implemented this as a separate crate - not sure if the reqwest maintainers want to use it directly.

/// HTTP Content-Range response header representation.
pub enum ContentRange {
    /// Regular bytes range response with status 206
    Bytes(ContentRangeBytes),
    /// Regular bytes range response with status 206
    UnboundBytes(ContentRangeUnbound),
    /// Server response with status 416
    Unsatisfied(ContentRangeUnsatisfied),
    /// Header cannot be parsed. This includes non-standard response with status 206
    Unknown,
}

pub struct ContentRangeBytes {
    pub first_byte: u64,
    pub last_byte: u64,
    pub complete_length: u64,
}

pub struct ContentRangeUnbound {
    pub first_byte: u64,
    pub last_byte: u64,
}

pub struct ContentRangeUnsatisfied {
    pub complete_length: u64,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant