Repository navigation
range: a suffix range longer than the content selects all of it - #4026
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4026 +/- ##
============================================
- Coverage 94.18% 94.16% -0.02%
+ Complexity 6656 6653 -3
============================================
Files 432 432
Lines 20897 20897
Branches 2096 2096
============================================
- Hits 19682 19678 -4
- Misses 762 764 +2
- Partials 453 455 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jknack
approved these changes
Oct 26, 2026
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.
ByteRange.parsecomputes the start of a suffix range (bytes=-N) ascontentLength - N. WhenNis larger than the content, the start is negative. For a 1000-byte file,Range: bytes=-2000gives aSingleByteRangethat starts at-1000. Netty then fails withIllegalArgumentException: position : -1000 (expected: >= 0)inDefaultFileRegion, and the client gets a broken response (a 400 logged after the headers, then a closed connection).RFC 9110 section 14.1.3 says: "If the selected representation is shorter than the specified suffix-length, the entire representation is used." So the request should get
206withContent-Range: bytes 0-999/1000. Media players and download managers send suffix ranges to read trailing metadata, and they don't know the length in advance.The start is now
Math.max(0, contentLength - end).bytes=-0still gives 416, because the start is then past the end.The new case in
ByteRangeTest.byteRange(bytes=-300on 200 bytes: start 0,bytes 0-199/200) fails without the change (expected: <0> but was: <-100>).mvn -pl jooby testpasses, andspotless:checkreports no violations in the changed files.