Boost C++ Libraries

PrevUpHomeNext

Function parse_range

boost::taar::parse_range — Parse a Range header value against a representation of size bytes (RFC 9110 14.1.2).

Synopsis

// In header: <boost/taar/core/byte_range.hpp>


range_set parse_range(std::string_view header, std::uint64_t size, 
                      std::size_t max_ranges = 16);

Description

Supports the bytes unit (case-insensitive) with first-last, first- and suffix -length specs, comma separated with optional whitespace. Ranges extending past the end are clipped; ranges starting at or after the end, and -0, are dropped as unsatisfiable. Large numbers saturate instead of overflowing.

Parameters:

header

The field value, e.g. bytes=0-499,-100.

size

The representation length in bytes.

max_ranges

More range specs than this make the header ignored, a defence against range amplification.

Returns:

ignored for a malformed header, another unit, a spec with last < first, or too many specs; unsatisfiable when no spec overlaps; otherwise satisfiable with the clipped ranges.


PrevUpHomeNext