The Range class is accessible via the webob.byterange module.
This only represents bytes ranges, which are the only kind specified in HTTP. This can represent multiple sets of ranges, but no place else is this multi-range facility supported.
Returns true if this range can be satisfied by the resource with the given byte length.
If there is only one range, and if it is satisfiable by the given length, then return a (begin, end) non-inclusive range of bytes to serve. Otherwise return None
If length is None (unknown length), then the resulting range may be (begin, None), meaning it should be served from that point. If it's a range with a fixed endpoint we won't know if it is satisfiable, so this will return None.
Works like range_for_length; returns None or a ContentRange object
You can use it like:
response.content_range = req.range.content_range(response.content_length)
Though it's still up to you to actually serve that content range!
Parse a Range header into (bytes, list_of_ranges). Note that the ranges are inclusive (like in HTTP, not like in Python typically).
Will return None if the header is invalid
Converts the list-of-ranges from parse_bytes() to a Python-style list of ranges (non-inclusive end points)
In the list of ranges, the last item can be None to indicate that it should go to the end of the file, and the first item can be negative to indicate that it should start from an offset from the end. If you give a length then this will not occur (negative numbers and offsets will be resolved).
If length is given, and any range is not value, then None is returned.
Converts a Python-style list of ranges to what serialize_bytes expects.
This is the inverse of bytes_to_python_ranges
See the source for more information.