Repository navigation
Serve the whole body for a suffix range longer than it - #2615
Merged
Merged
Conversation
RFC 9110 14.1.2: if the representation is shorter than the suffix-length, the entire representation is used. range_error computed a negative first byte position for bytes=-8 on a 7-byte body and answered 416. Clamp it at 0, as yhirose#711 did before the range handling was reworked.
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.
A suffix range longer than the body is answered with 416:
Rangeon a 7-byte bodynet/httpbytes=-7bytes 0-6/7bytes 0-6/7bytes 0-6/7bytes=-8,bytes=-9999bytes 0-6/7bytes 0-6/7bytes=-0RFC 9110 §14.1.2: "If the selected representation is shorter than the specified suffix-length, the entire representation is used." In
range_error,first_pos = content_len - last_posgoes negative and fails the validity check below it. #711 clamped this at 0; the clamp was lost when fceada9 reworked range handling, andGetStreamedWithRangeSuffix2was changed to expect 416. #2009 restored the other half of the same paragraph (a last-byte-pos past the end means the remainder); this does the same for the suffix form.coalesce_rangeshas the same arithmetic, but it only sees rangesrange_errorhas already normalized.GetStreamedWithRangeSuffix2now expects the whole body forbytes=-8andbytes=-9999, and the 416 assertions move toGetStreamedWithRangeSuffixZerowithbytes=-0. Clamping at 1 instead of 0, or not at all, fails the new expectations. With g++ and the Makefile's flags (ASan, no TLS),*Range*(43) andServerTest.*(188) pass andclang-format --dry-run --Werroris clean; I did not run the TLS builds or the full CI matrix.Written with AI assistance (Claude); I have reviewed the change.