Repository navigation
Skip unsatisfiable ranges instead of rejecting the whole Range set - #2703
Merged
yhirose merged 2 commits intoNov 30, 2026
Merged
Conversation
RFC 9110 14.1.1: a byte-range-set is satisfiable when any of its ranges is, and 15.5.17 keeps 416 for when none of them are. range_error() answered 416 as soon as one range started past the end of the body. Leave such ranges out and serve the rest.
The list used for the overlap check and the list of ranges to serve always held the same values. Also drop a test assertion that could never fail.
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
range_error()answers 416 as soon as one range in the set is past the end of the body, so on the 7-byte/with-rangeresponsegets 416 instead of the two parts it can serve. RFC 9110 Section 14.1.1 says the set is satisfiable when any of its ranges is (a first-pos below the length, or a non-zero suffix-length), and Section 15.5.17 keeps 416 for when none of them are. Range parts that cannot be satisfied are left out of the 206.
The change skips an unsatisfiable range instead of returning, serves the rest, and returns 416 only when no range is left. The limits on the number of ranges and on overlapping ranges are unchanged, and only the ranges that are served count toward the overlap limit.
GetWithRangeMultipartOffsetGreaterThanContentexpected 416 forbytes=-2, 10000-30000. It now expects the last two bytes (bytes 5-6/7), the same way #2615 changedbytes=-9999. New tests:GetWithRangeMultipartSkipsUnsatisfiableRange: the range set above gives the same multipart body asbytes=1-2, 4-5.GetWithRangeMultipartNoneSatisfiable:bytes=7-, -0andbytes=10000-30000, 7-8still get 416.GetStreamedWithRangeSkipsUnsatisfiableRange:bytes=7-, 2-3on a content provider givesbytes 2-3/7.All three range-skipping tests fail with the current httplib.h (416) and pass with the change. Built with the test Makefile (g++ 11, ASan, OpenSSL) on Linux, the non-online tests pass. clang-format leaves the changed lines as they are.