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

ShallowEtagHeaderFilter should write body early when HttpServletResponse.sendError() is called [SPR-11705] #16327

Closed
spring-projects-issues opened this issue Apr 18, 2014 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 18, 2014

Dmitry Goncharov opened SPR-11705 and commented

Third party Servlet (in my case it's Jersey 2) is wrapped by org.springframework.web.filter.ShallowEtagHeaderFilter

In some cases Servlet need to write custom error response. Servlet do it in following way: add headers, write error response body and send error response code by calling response.sendError() method.

ShallowEtagHeaderFilter postpone response body writing, so actual body writing is performed in ShallowEtagHeaderFilter#copyBodyToResponse
after sendError method invocation.
response.sendError commits wrapped response, therefore ShallowEtagHeaderFilter#copyBodyToResponse is performed on committed response. This leads to wrong response content.

Proposed solution: Force content writing in org.springframework.web.filter.ShallowEtagHeaderFilter.ShallowEtagResponseWrapper when sendError or sendRedirect is called.


Affects: 3.0.5

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

It's a little unusual to write body content first and then call sendError... since sendError is supposed to trigger the container's error page. If all you wanted is an error status code with custom content, you'd use setStatus instead.

In any case, since Jersey does it that way, we're going to support it in ShallowEtagHeaderFilter as of Spring 4.0.4.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants