Bug 29214

Summary: response containsHeader("Content-Type") not working
Product: Tomcat 4 Reporter: sean <srdrucker>
Component: Servlet & JSP APIAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 4.1.24   
Target Milestone: ---   
Hardware: All   
OS: All   

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");
System.out.println(response.containsHeader("Content-Type"));

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.