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

HeaderWriterFilter appears to be violating Servlet spec #12025

Open
vpavic opened this issue Oct 14, 2022 · 3 comments
Open

HeaderWriterFilter appears to be violating Servlet spec #12025

vpavic opened this issue Oct 14, 2022 · 3 comments
Labels
in: web An issue in web modules (web, webmvc) status: feedback-provided Feedback has been provided type: bug A general bug

Comments

@vpavic
Copy link
Contributor

vpavic commented Oct 14, 2022

Servlet spec states that include dispatch:

... cannot set headers or call any method that affects the headers of the response... Any attempt to set the headers must be ignored...

HeaderWriterFilter appears to be at odds with this as it invokes HeaderWriterResponse#onResponseCommitted in HeaderWriterRequestDispatcher#include, which in turn calls HeaderWriterResponse#writeHeaders.

@vpavic vpavic added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Oct 14, 2022
@marcusdacoregio marcusdacoregio added in: web An issue in web modules (web, webmvc) and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 21, 2022
@marcusdacoregio
Copy link
Contributor

marcusdacoregio commented Oct 21, 2022

Hi @vpavic, thanks for the report.

There is a reason for this on #5499.
Do you think that scenario makes sense?

@marcusdacoregio marcusdacoregio added the status: waiting-for-feedback We need additional information before we can continue label Oct 27, 2022
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 3, 2022
@vpavic
Copy link
Contributor Author

vpavic commented Nov 10, 2022

Sorry for the late reply.

I ran into the issue you linked (and some other related ones) shortly after opening this. Overall, I think the arrangement does make sense, but the point that I tried to make is that it's still possible for HeaderWriterFilter to attempt to write headers from an include.

Assuming the request that invokes RequestDispatcher#include itself isn't filtered by HeaderWriterFilter, but the one that is being included is, HeaderWriterFilter#writeHeaders will end up being called but headers won't be written to the response by the container (because the spec states that attempt to set the headers must be ignored in such case).

To make things more explicit, and avoid any confusion that might come as a result of the fact that HeaderWriterFilter#writeHeaders is called but response headers are not written, HeaderWriterFilter could override OncePerRequestFilter#shouldNotFilter and skip filtering for requests of include dispatcher type.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Nov 10, 2022
@marcusdacoregio marcusdacoregio removed their assignment May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) status: feedback-provided Feedback has been provided type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants