joerghoh commented on code in PR #106:
URL: 
https://github.com/apache/sling-org-apache-sling-engine/pull/106#discussion_r4537577908


##########
src/main/java/org/apache/sling/engine/impl/DefaultErrorHandler.java:
##########
@@ -133,6 +156,29 @@ private void delegateFailed(
         sendError(originalStatus, originalMessage, null, request, response);
     }
 
+    protected JakartaErrorHandler getErrorHandler(final 
SlingJakartaHttpServletRequest request) {
+        final JakartaErrorHandler nonHtml = this.nonHtmlDelegate;
+        if (this.enableAcceptHeaderCheck && nonHtml != null && 
!acceptsHtml(request)) {
+            return nonHtml;
+        }
+        return this.delegate;
+    }
+
+    /**
+     * A request accepts html if it explicitly accepts {@code text/html} or 
{@code *}{@code /*}.
+     * A missing accept header and partial wildcards like {@code text/*} are 
not considered html.
+     * Only the accept header is evaluated: request parameters are not read, 
as parameter
+     * parsing might itself be the cause of the error being handled.
+     */
+    private static boolean acceptsHtml(final SlingJakartaHttpServletRequest 
request) {
+        final String accept = 
request.getHeader(JakartaMediaRangeList.HEADER_ACCEPT);
+        if (accept == null || accept.trim().isEmpty()) {
+            return false;
+        }
+        // TODO - do we want to treat */* as html?

Review Comment:
   SLING-13416 fixes the MediaRangeList and impleents a proper handling of the 
catch-all ``*/*``. 



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