mirror of https://github.com/kiwix/libkiwix.git
Handling of unsatisfiable ranges
This commit is contained in:
parent
37032892a4
commit
c2ebdefe8d
|
@ -85,6 +85,9 @@ ByteRange ByteRange::resolve(int64_t contentSize) const
|
||||||
|
|
||||||
const int64_t resolved_last = std::min(contentSize-1, last());
|
const int64_t resolved_last = std::min(contentSize-1, last());
|
||||||
|
|
||||||
|
if ( resolved_first > resolved_last )
|
||||||
|
return ByteRange(INVALID, 0, contentSize-1);
|
||||||
|
|
||||||
return ByteRange(RESOLVED_PARTIAL_CONTENT, resolved_first, resolved_last);
|
return ByteRange(RESOLVED_PARTIAL_CONTENT, resolved_first, resolved_last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,7 +465,9 @@ TEST_F(ServerTest, InvalidAndMultiRangeByteRangeRequestsResultIn416Responses)
|
||||||
|
|
||||||
const char* invalidRanges[] = {
|
const char* invalidRanges[] = {
|
||||||
"0-10", "bytes=", "bytes=123", "bytes=-10-20", "bytes=10-20xxx",
|
"0-10", "bytes=", "bytes=123", "bytes=-10-20", "bytes=10-20xxx",
|
||||||
"bytes=10-0", "bytes=10-20, 30-40"
|
"bytes=10-0", // reversed range
|
||||||
|
"bytes=10-20, 30-40", // multi-range
|
||||||
|
"bytes=1000000-", "bytes=30000-30100" // unsatisfiable ranges
|
||||||
};
|
};
|
||||||
|
|
||||||
for( const char* range : invalidRanges )
|
for( const char* range : invalidRanges )
|
||||||
|
|
Loading…
Reference in New Issue