Bug 29214 - response containsHeader("Content-Type") not working
Summary: response containsHeader("Content-Type") not working
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 4.1.24
Hardware: All All
: P3 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2004-05-25 23:19 UTC by sean
Modified: 2006-01-08 14:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description sean 2004-05-25 23:19:22 UTC
response.containsHeader("Content-Type") always returns false even if the header
is explicitly added via response.setHeader("Content-Type", "text/html").

To reproduce, simply add the following to a filter or servlet:

response.setHeader("Content-Type", "text/html");

The difficult question (for which the Servlet spec is silent) will be what to
return for response.containsHeader("Content-Type") if the header was set using
the response.setContentType() method.  I think the spec is pretty clear that if
setHeader is used, containsHeader should work for any header.

Thanks... Sean
Comment 1 Mark Thomas 2006-01-08 23:51:20 UTC
This has now been fixed in SVN.

Based on the wording on the spec for setContentLength() which states that
calling this method sets the Content-Length header for HTTP servlets,
containsHeader() now returns true if the Content-Length or Content-Type has been
set directly by setHeader or indirectly by setContentLength() etc.