}
// one range
if (ranges.size() == 1)
{
Range range = ranges.get(0);
if (!validateRange(range, contentLength))
return Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE).header(
ExtHttpHeaders.CONTENTRANGE, "bytes */" + contentLength).build();
long start = range.getStart();
long end = range.getEnd();
long returnedContentLength = (end - start + 1);
RangedInputStream rangedInputStream = new RangedInputStream(istream, start, end);
return Response.status(HTTPStatus.PARTIAL)
.header(HttpHeaders.CONTENT_LENGTH, Long.toString(returnedContentLength))
.header(ExtHttpHeaders.ACCEPT_RANGES, "bytes")
.header(ExtHttpHeaders.LAST_MODIFIED, lastModifiedProperty.getValue())
.header(ExtHttpHeaders.CONTENTRANGE, "bytes " + start + "-" + end + "/" + contentLength)
.entity(rangedInputStream).type(contentType).build();
}
// multipart byte ranges as byte:0-100,80-150,210-300
for (int i = 0; i < ranges.size(); i++)
{
Range range = ranges.get(i);
if (!validateRange(range, contentLength))
return Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE).header(
ExtHttpHeaders.CONTENTRANGE, "bytes */" + contentLength).build();
ranges.set(i, range);
}