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().
*** Bug 3882 has been marked as a duplicate of this bug. ***
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.
*** Bug 6612 has been marked as a duplicate of this bug. ***
Reopen.
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.