in src/main/java/org/apache/sling/servlets/get/impl/helpers/StreamRenderer.java [345:381]
private void setHeaders(Resource resource, SlingJakartaHttpServletResponse response) {
final ResourceMetadata meta = resource.getResourceMetadata();
final long modifTime = meta.getModificationTime();
if (modifTime > 0) {
response.setDateHeader(HEADER_LAST_MODIFIED, modifTime);
}
final String defaultContentType = "application/octet-stream";
String contentType = meta.getContentType();
if (contentType == null || defaultContentType.equals(contentType)) {
// if repository doesn't provide a content-type, or
// provides the
// default one,
// try to do better using our servlet context
final String ct = context.getMimeType(resource.getPath());
if (ct != null) {
contentType = ct;
}
}
if (contentType == null) {
contentType = defaultContentType;
}
response.setContentType(contentType);
String encoding = meta.getCharacterEncoding();
if (encoding != null) {
response.setCharacterEncoding(encoding);
}
// announce support for ranges if we know the size to be larger than 100KB
if (meta.getContentLength() > ACCEPT_RANGES_THRESHOLD) {
response.setHeader(ACCEPT_RANGES_HEADER, ACCEPT_RANGES_BYTES);
}
}