Bug 57601 - DefaultServlet returns no content when included during a HEAD request
Summary: DefaultServlet returns no content when included during a HEAD request
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: All All
: P5 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks: 37466 57602
  Show dependency tree
 
Reported: 2015-02-19 07:57 UTC by Jeremy Boynes
Modified: 2015-03-02 11:44 UTC (History)
0 users



Attachments
Patch with test case and possible fix (5.18 KB, patch)
2015-02-19 08:05 UTC, Jeremy Boynes
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Boynes 2015-02-19 07:57:32 UTC
During a HEAD request, when a RequestDispatcher include is handled by the DefaultServlet the content of the static resource is not written to the HttpServletResponse. If the including servlet has wrapped the response before performing the include it will not receive the content of the resource.

This causes an issue for the JSTL <c:import> tag when a relative url is used in order to retrieve the resource, for example for use with the <x:parse> tag. Bug 37466 describes this case.

It is also a problem for other requests where the response headers may be affected by this lack of content causing different header values to be returned for GET vs. HEAD methods. For example, the Content-Length header does not account for bytes that are emitted by the included resource.
Comment 1 Jeremy Boynes 2015-02-19 08:05:24 UTC
Created attachment 32497 [details]
Patch with test case and possible fix

Patch that adds a test cases checking the Content-Length for GET and HEAD requests to a JSP page that includes a static resource.

Possible fix by checking the DispatcherType in DefaultServlet#doHead()
Comment 2 Mark Thomas 2015-03-02 11:44:46 UTC
Fixed in trunk, 8.0.x for 8.0.21 onwards and in 7.0.x for 7.0.60 onwards.