Single byte range request looks like: bytes=0-100
, bytes=100-
,
bytes=-100
.
Multiple byte range request are not supported.
- Since:
- 2.0.0
- Author:
- edgar
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionFor partial request this method set the following byte range response headers:apply
(InputStream input) For partial requests this method generates a new truncated input stream.long
New content length.Value forContent-Range
response header.long
getEnd()
End range or-1
.long
getStart()
Start range or-1
.For partial requests this method returnsStatusCode.PARTIAL_CONTENT
.static ByteRange
Parse a byte range request value.
-
Field Details
-
BYTES_RANGE
Byte range prefix.- See Also:
-
-
Method Details
-
parse
Parse a byte range request value. Example of valid values:- bytes=0-100 - bytes=-100 - bytes=100-
Any non-matching values produces a not satisfiable response.
If value is null or content length less or equal to
0
, produces an empty/NOOP response.- Parameters:
value
- Valid byte range request value.contentLength
- Content length.- Returns:
- Byte range instance.
-
getStart
long getStart()Start range or-1
.- Returns:
- Start range or
-1
.
-
getEnd
long getEnd()End range or-1
.- Returns:
- End range or
-1
.
-
getContentLength
long getContentLength()New content length.- Returns:
- New content length.
-
getContentRange
Value forContent-Range
response header.- Returns:
- Value for
Content-Range
response header.
-
getStatusCode
For partial requests this method returnsStatusCode.PARTIAL_CONTENT
.For not satisfiable requests this returns
StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
..Otherwise just returns
StatusCode.OK
.- Returns:
- Status code.
-
apply
For partial request this method set the following byte range response headers:- Accept-Ranges - Content-Range - Content-Length
For not satisfiable requests:
- Throws a
StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
Otherwise this method does nothing.
- Parameters:
ctx
- Web context.- Returns:
- This byte range request.
-
apply
For partial requests this method generates a new truncated input stream.For not satisfiable requests this method throws an exception.
If there is no range to apply this method returns the given input stream.
- Parameters:
input
- Input stream.- Returns:
- A truncated input stream for partial request or same input stream.
- Throws:
IOException
- When truncation fails.
-