public interface ByteRange
bytes=0-100
, bytes=100-
,
bytes=-100
.
Multiple byte range request are not supported.Modifier and Type | Field and Description |
---|---|
static String |
BYTES_RANGE
Byte range prefix.
|
Modifier and Type | Method and Description |
---|---|
ByteRange |
apply(Context ctx)
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. |
InputStream |
apply(InputStream input)
For partial requests this method generates a new truncated input stream.
|
long |
getContentLength()
New content length.
|
String |
getContentRange()
Value for
Content-Range response header. |
long |
getEnd()
End range or
-1 . |
long |
getStart()
Start range or
-1 . |
StatusCode |
getStatusCode()
For partial requests this method returns
StatusCode.PARTIAL_CONTENT . |
static ByteRange |
parse(String value,
long contentLength)
Parse a byte range request value.
|
static final String BYTES_RANGE
@Nonnull static ByteRange parse(@Nullable String value, long contentLength)
0
, produces an empty/NOOP
response.value
- Valid byte range request value.contentLength
- Content length.long getStart()
-1
.-1
.long getEnd()
-1
.-1
.long getContentLength()
@Nonnull String getContentRange()
Content-Range
response header.Content-Range
response header.@Nonnull StatusCode getStatusCode()
StatusCode.PARTIAL_CONTENT
.
For not satisfiable requests this returns StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
..
Otherwise just returns StatusCode.OK
.@Nonnull ByteRange apply(@Nonnull Context ctx)
StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
Otherwise this method does nothing.ctx
- Web context.@Nonnull InputStream apply(@Nonnull InputStream input) throws IOException
input
- Input stream.IOException
- When truncation fails.Copyright © 2020. All rights reserved.