Bug 3878 - Multiple Content-Type and Content-Length headers in response
Summary: Multiple Content-Type and Content-Length headers in response
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 4.0 Final
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 3882 6612 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-09-28 14:46 UTC by Carl Hamilton
Modified: 2005-03-20 17:06 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Hamilton 2001-09-28 14:46:03 UTC
The following servlet will generate an HTTP response with two Content-Type 
headers and two Content-Length headers.

    import javax.servlet.http.*;

    public class HeaderBug extends HttpServlet {
        protected void doGet(HttpServletRequest request, HttpServletResponse 
response) {
            response.setHeader("Content-Type", "text/xml");
            response.setContentType("text/html");
            response.setIntHeader("Content-Length", 200);
            response.setContentLength(100);
        }
    }

It looks like the way HttpResponseBase.setHeader() HttpResponseBase.sendHeaders
() are treating these two headers doesn't play well with 
ResponseBase.setContentType() and ResponseBase.setContentLength().
Comment 1 Remy Maucherat 2001-09-28 17:57:23 UTC
*** Bug 3882 has been marked as a duplicate of this bug. ***
Comment 2 Remy Maucherat 2001-09-29 11:48:14 UTC
Will be fixed in an upcoming version of the HTTP connector. The current version 
won't prevent breaking the protocol by setting the headers incorrectly.
Comment 3 Remy Maucherat 2002-02-21 17:13:32 UTC
*** Bug 6612 has been marked as a duplicate of this bug. ***
Comment 4 Remy Maucherat 2002-03-15 10:01:24 UTC
Reopen.
Comment 5 Remy Maucherat 2002-03-15 10:19:56 UTC
The new HTTP connector prevents many attempt to break the protocol. It would be
too expensive to fully validate everything, but this particular case, which is
quite common, is now handled well.