Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jooby/src/main/java/io/jooby/ByteRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static ByteRange parse(@Nullable String value, long contentLength) {
long start = range[0];
long end = range[1];
if (start == -1) {
start = contentLength - end;
// A suffix longer than the content selects all of it.
start = Math.max(0, contentLength - end);
end = contentLength - 1;
}
if (end == -1 || end > contentLength - 1) {
Expand Down
10 changes: 10 additions & 0 deletions jooby/src/test/java/io/jooby/ByteRangeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public void byteRange() {
assertEquals("bytes 101-199/200", range.getContentRange());
});

range(
"bytes=-300",
200,
range -> {
assertEquals(PARTIAL_CONTENT, range.getStatusCode());
assertEquals(0, range.getStart());
assertEquals(200, range.getEnd());
assertEquals("bytes 0-199/200", range.getContentRange());
});

// 100-150 is ignored.
range(
"bytes=0-50, 100-150",
Expand Down
Loading