Skip to content

Support DispatcherType.INCLUDE in DefaultServletHttpRequestHandler #30113

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

Conversation

bergander
Copy link
Contributor

When serving static resources by enabling the DefaultServletHttpRequestHandler you will get an IllegalStateException (Response already commited) error when importing a static resource.

I believe this is caused by the fact that DefaultServletHttpRequestHandler.handleRequest(...) is always calling RequestDispatcher.forward(...) which will set the response to commited. If it were to check the dispatcher type and instead call RequestDispatcher.include(...) when the dispatcher type of the request is set to DispatcherType.INCLUDE, then everything works as expected.

if (request.getDispatcherType() == DispatcherType.INCLUDE) {
	rd.include(request, response);
} else {
	rd.forward(request, response);
}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 13, 2023
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Mar 14, 2023
@rstoyanchev rstoyanchev self-assigned this Sep 20, 2023
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 20, 2023
@rstoyanchev rstoyanchev added this to the 6.1.0-RC1 milestone Sep 20, 2023
@rstoyanchev rstoyanchev changed the title Fix DefaultServletHttpRequestHandler not compatible with DispatcherType.INCLUDE Support DispatcherType.INCLUDE in DefaultServletHttpRequestHandler Sep 20, 2023
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

Successfully merging this pull request may close these issues.

3 participants