public class SingleByteRange extends Object implements ByteRange
bytes=0-100
, bytes=100-
,
bytes=-100
.
Multiple byte range request are not supported.BYTES_RANGE
Constructor and Description |
---|
SingleByteRange(String value,
long start,
long end,
long contentLength,
String contentRange) |
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 . |
String |
toString() |
public long getStart()
-1
.public long getEnd()
-1
.public long getContentLength()
getContentLength
in interface ByteRange
@Nonnull public String getContentRange()
Content-Range
response header.getContentRange
in interface ByteRange
Content-Range
response header.@Nonnull public StatusCode getStatusCode()
ByteRange
StatusCode.PARTIAL_CONTENT
.
For not satisfiable requests this returns StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
..
Otherwise just returns StatusCode.OK
.getStatusCode
in interface ByteRange
@Nonnull public ByteRange apply(@Nonnull Context ctx)
StatusCode.REQUESTED_RANGE_NOT_SATISFIABLE
Otherwise this method does nothing.@Nonnull public InputStream apply(@Nonnull InputStream input) throws IOException
apply
in interface ByteRange
input
- Input stream.IOException
- When truncation fails.Copyright © 2020. All rights reserved.