joerghoh commented on code in PR #26:
URL: 
https://github.com/apache/sling-org-apache-sling-servlets-get/pull/26#discussion_r4537276678


##########
src/main/java/org/apache/sling/servlets/get/impl/helpers/StreamRenderer.java:
##########
@@ -301,6 +305,18 @@ private void renderDirectory(
 
                 setHeaders(fileRes, response);
 
+                final boolean noExtension = index.indexOf('.') < 0;
+
+                // An index resource without extension is rendered through 
"<path>.html", so the
+                // response is HTML. Fall back to text/html when no better 
content type is known,
+                // and do it before the HEAD check so that HEAD and GET report 
the same type.
+                if (noExtension) {
+                    String contentType = response.getContentType();
+                    if (contentType == null || 
contentType.startsWith(CONTENT_TYPE_APPLICATION_OCTET_STREAM)) {

Review Comment:
   this check is wrong.
   
   ``setHeaders()`` does not necessarily set the content-type to 
``application/octet-stream`` in all cases when the resource does not have an 
extension. It's just an assumption, that all resources, which don't have an 
extension have no explicit mime-type set (or anything else, which causes 
``setHeaders()`` set the content-type differently).
   
   For this we should set the content-type to ``text/html`` AND forward to the 
HTML rendition only under the very same condition:
   1.  either whenever the resource does not have an extension
   2. or if it does not have an extension and the content-type is set to 
``application/octet-stream`` by ``setHeaders()``.
   
   but we must not have a mix of these 2. My personal preference is (1).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to