parse_byte_ranges

Function parse_byte_ranges 

Source
pub fn parse_byte_ranges(
    raw: &str,
    total_size: u64,
    maximum_raw_bytes: usize,
    maximum_specs: usize,
) -> Result<HttpByteRangeSet, HttpRangeError>
Expand description

Parses an RFC 9110 bytes range-set with allocation, work, and raw-input bounds.

maximum_raw_bytes is checked before inspecting or allocating for the range-set. Empty list members are tolerated as required by the HTTP #rule recipient grammar. Every non-empty spec must be syntactically valid, while individually unsatisfiable specs are removed as long as at least one requested range remains satisfiable. End bounds beyond the current representation are clamped and suffix ranges larger than the representation select it all.

ยงErrors

Returns an error when the raw header exceeds maximum_raw_bytes, the range-set exceeds maximum_specs, the unit or syntax is invalid, a bound is not an unsigned integer, or no range is satisfiable for the current representation.