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


##########
src/main/java/org/apache/sling/servlets/get/impl/helpers/StreamRenderer.java:
##########
@@ -301,6 +305,15 @@ 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 always HTML, no matter which content type 
setHeaders() determined for
+                // the resource itself. Do it before the HEAD check so HEAD 
and GET report the same type.
+                if (noExtension) {
+                    response.setContentType(CONTENT_TYPE_TEXT_HTML);
+                }

Review Comment:
   Thanks, I see the point about keeping the logic in one place. The reason I 
set the content
   type above is the HEAD early return: for a HEAD request the method returns 
before reaching
   the dispatcher block, so if the content type is only set there, HEAD would 
not report
   text/html while GET does (and HEAD is expected to return the same headers as 
GET). There is
   also a test covering exactly that case.
   
   I'm happy to restructure it if you prefer, e.g. by moving the HEAD check 
below the
   dispatcher selection so both live under the same condition. Otherwise I'd 
keep it as is.
   Let me know what you think.



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