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


##########
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:
   Thanks for the review, @joerghoh, and for pointing this out. The forward to 
"<path>.html" and
   the content type were decided by different conditions, so I've aligned them 
following your
   first option: whenever the index resource has no extension, the content type 
is set to
   text/html and the request is forwarded to the HTML rendition, regardless of 
what
   setHeaders() determined for the resource itself.
   
   I also added a test with an extensionless index that has its own content 
type (text/plain),
   to cover that case. Happy to adjust anything else if needed.



-- 
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