[ https://issues.apache.org/jira/browse/SLING-13413 ]
Carsten Ziegeler deleted comment on SLING-13413:
------------------------------------------
was (Author: cziegeler):
We could split up error handling into named error handlers (via service
registration property). Via configuration it is possible to select an error
handler based on Accept-Header.
The current error handling will by default be registered for text/html.
A new provided "StatusErrorHandler" will handle by default all other response
types and just set the status code (resetting content/content length)
Configuration allow for example to send json responses to the current error
handler or to a completely new error handler.
> Provide different error handlers for non-HTML/non-JSON requests
> ---------------------------------------------------------------
>
> Key: SLING-13413
> URL: https://issues.apache.org/jira/browse/SLING-13413
> Project: Sling
> Issue Type: Improvement
> Components: Engine, Servlets
> Affects Versions: Engine 3.0.4, Servlets Resolver 3.0.10
> Reporter: Joerg Hoh
> Assignee: Joerg Hoh
> Priority: Major
>
> Right now, when a request to a non-HTML resource fails, the registered
> ErrorHandler is used - which usually is the SlingServletResolver delegating
> to a script registered in the resource tree.
> The default built-in scripts as well as most of the custom script are notÂ
> built to explicitly handle requests to non-HTML resources and therefor always
> returns either JSON (if the accept header indicates JSON) or HTML for
> eveything else.
> In that case, a request to /content/non-existing-image.png will often returns
> the HTML error page, even if the browser indicated in the accept header, that
> it won't handle text/html for this request. Next to potential security
> problems this can cause performance problems if the creation of the error
> page is expensive.
> We need to have a dedicated handling for non-JSON and non-HTML responses,
> which just set the statuscode. No response body is required in these cases.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)