Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLING-11722 - The SlingRequestDispatcher doesn't correctly implement the RequestDispatcher API #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ If a servlet or script is including another resource for processing through the

1. The resource is resolved though ResourceResolver.getResource (if the RequestDispatcher has not been created with a resource already)

1. The servlet or script to handle the resource is resolved calling the `ServletResolver.resolverServlet` method.
1. The servlet or script to handle the resource is resolved calling the `ServletResolver.resolveServlet` method.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a typo, but since I was here... :)


1. The component level filters (registered with the property `filter.scope=component`) are called again (see [Filters](/documentation/the-sling-engine/filters.html) for details).

1. The servlet or script is called to process the request.

Note that these steps are processed for every include or forward call.

Starting with version 2.13.2 of the `org.apache.sling.engine` bundle, the `RequestDispatcher` implementation from Apache Sling can be configured
to be fully spec-compliant when it comes to processing includes via the
[`include` method](https://docs.oracle.com/javaee/7/api/javax/servlet/RequestDispatcher.html#include-javax.servlet.ServletRequest-javax.servlet.ServletResponse-),
namely to not allow included servlets to set the response status code or set any response headers. Two new configuration options for the
`org.apache.sling.engine.impl.SlingMainServlet` facilitate this behavior:

1. `sling.includes.protectheaders` - when enabled, servlets included via the `RequestDispatcher` will not be able to change the response status code or set headers. Any attempt to make a change is ignored. This behaviour can be overridden per include via the 'protectHeadersOnInclude' RequestDispatcherOptions key;

1. `sling.includes.checkcontenttype` - when enabled, in addition to not allowing servlets included via the `RequestDispatcher` to change the response status code or set headers, it will also check explicit overrides of the `Content-Type` header and will make the Sling Engine throw a `RuntimeException` when such an override is detected.


## Included Request Attributes

Expand Down