WB uses tornado’s
httputil._parse_request_rangefunction to parse the Range HTTP header and return a tuple representing the range. Tornado’s version returns a tuple suitable for slicing arrays, meaning that a range of 0-1 will be returned as
(0, 2). WB had been assuming that the tuple would represent the first and last byte positions and was consistently returning one more byte than requested. Since WB doesn’t ever use ranges to do list slicing of byte streams, this function wraps tornado’s version and returns the actual byte indices.
Range: bytes=0-1will be returned as
If the end byte is omitted, the second element of the tuple will be
None. This will be sent to the provider as an open ended range, e.g. (
Range: bytes=5-). Most providers interpret this to mean “send from the start byte to the end of the file”.
If this function receives an unsupported or unfamiliar Range header, it will return
None, indicating that the full file should be sent. Some formats supported by other providers but unsupported by WB include:
Range: bytes=-5– some providers interpret this as “send the last five bytes”
Range: bytes=0-5,10-12– indicates a multi-range, “send the first six bytes, then the next three bytes starting from the eleventh”.
Unfamiliar byte ranges are anything not matching
^bytes=[0-9]+\-[0-9]*$, or ranges where the end byte position is less than the start byte.
Parameters: range_header (str) – a string containing the value of the Range header Return type:
tuplerepresenting the inclusive range of byte positions or