You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Range header is one of the least useful header types in this library. Most of these problems stem from the fact that it contains only a string HeaderValue, instead of a parsed representation of the Range.
The internal representation of range endpoints passed to bytes and returned from satisfiable_ranges is Bound<u64>. But this is a very poor fit, because it suggests in the return type that Bound::Excluded would be a valid value to use in a Range header, when it is actually never possible for it to appear.
headers should re-introduce the ByteRangeSpec enum to encode the three valid cases for the Range header.
Range::bytes allows construction from a single impl RangeBounds<u64>. Range should be extended to allow construction from impl Iterator<ByteRangeSpec>.
The internal representation of a Range is a string cloned from the HeaderValue passed to decode. It should instead be a collection of ByteRanges, perhaps a SmallVec<[ByteRangeSpec; 1]> since the expected case is that there will only be one range (multipart ranges are generally uncommon).
If you are constructing or parsing this header, it is expected that you are going to access the fields, so the extra memory overhead of doing so is explicitly necessary. And the type already clones the string header value! Doing the SmallVec optimization would reduce the number of allocations by 1 for the typical case.
satisfiable_ranges assumes the caller will know the size of the resource being fetched. It may not, in which case passing u64::MAX will return nonsense results when a suffix range is parsed.
The text was updated successfully, but these errors were encountered:
The
Range
header is one of the least useful header types in this library. Most of these problems stem from the fact that it contains only a stringHeaderValue
, instead of a parsed representation of theRange
.The internal representation of range endpoints passed to
bytes
and returned fromsatisfiable_ranges
isBound<u64>
. But this is a very poor fit, because it suggests in the return type thatBound::Excluded
would be a valid value to use in aRange
header, when it is actually never possible for it to appear.headers
should re-introduce theByteRangeSpec
enum to encode the three valid cases for theRange
header.Range::bytes
allows construction from a singleimpl RangeBounds<u64>
.Range
should be extended to allow construction fromimpl Iterator<ByteRangeSpec>
.The internal representation of a
Range
is a string cloned from theHeaderValue
passed todecode
. It should instead be a collection ofByteRange
s, perhaps aSmallVec<[ByteRangeSpec; 1]>
since the expected case is that there will only be one range (multipart ranges are generally uncommon).If you are constructing or parsing this header, it is expected that you are going to access the fields, so the extra memory overhead of doing so is explicitly necessary. And the type already clones the string header value! Doing the SmallVec optimization would reduce the number of allocations by 1 for the typical case.
satisfiable_ranges
assumes the caller will know the size of the resource being fetched. It may not, in which case passingu64::MAX
will return nonsense results when a suffix range is parsed.The text was updated successfully, but these errors were encountered: