Bug 53627 - Content-Type header not written after dispatch via AsyncContext
Summary: Content-Type header not written after dispatch via AsyncContext
Status: RESOLVED DUPLICATE of bug 53624
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.29
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-31 01:26 UTC by Rossen Stoyanchev
Modified: 2012-08-14 22:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rossen Stoyanchev 2012-07-31 01:26:45 UTC
After a dispatch via AsyncContext, the 'Content-Type' header does not appear in the response on the client side even though it is set on the server side via response.setContentType(String).

A project demonstrating the issue:
https://github.com/rstoyanchev/dispatch-test

Checkout the source from the 'tomcat-issue-repro' branch. When the application is deployed, from the home page choose the "JSON content" scenario. The scenario involves one Servlet that creates a thread and dispatches to a second Servlet that sets the contentType property of the response to "application/json" and writes some JSON content. However, the 'Content-Type' header does not appear in the response. For details on the setup see WebAppInitializer.setupJsonSecnario(ServletContext).

----

FWIW, if forwarding is used from the application thread instead of a dispatch through the AsyncContext, the response contains the 'Content-Type' header. To see that modify the line that sets up servlet "JsonA" in WebAppInitializer.setupJsonScenario(ServletContext) to create a ForwardingAsyncServlet instead of a DispatchingAsyncServlet.
Comment 1 Mark Thomas 2012-08-14 22:50:45 UTC
Same root cause - marking the dispatch as an include and thereby preventing the alteration of request headers.

*** This bug has been marked as a duplicate of bug 53624 ***