in src/main/java/org/apache/sling/servlets/get/impl/helpers/StreamRenderer.java [492:529]
private void copy(Resource resource, ServletOutputStream ostream, Iterator<Range> ranges) throws IOException {
String contentType = resource.getResourceMetadata().getContentType();
IOException exception = null;
while ((exception == null) && (ranges.hasNext())) {
InputStream resourceInputStream = resource.adaptTo(InputStream.class);
try (InputStream istream = new BufferedInputStream(resourceInputStream, IO_BUFFER_SIZE)) {
Range currentRange = ranges.next();
// Writing MIME header.
ostream.println();
ostream.println("--" + mimeSeparation);
if (contentType != null) {
ostream.println("Content-Type: " + contentType);
}
ostream.println("Content-Range: bytes " + currentRange.start + "-" + currentRange.end + "/"
+ currentRange.length);
ostream.println();
// Copy content
try {
copy(istream, ostream, currentRange);
} catch (IOException e) {
exception = e;
}
}
}
ostream.println();
ostream.print("--" + mimeSeparation + "--");
if (exception != null) {
throw exception;
}
}