DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5740>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5740

content-type reset to text/html on response with status >= 400

           Summary: content-type reset to text/html on response with status
                    >= 400
           Product: Tomcat 4
           Version: 4.0.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HTTP/1.1 Connector
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The following code for the doPost method of an HTTPServlet.  When you post to 
the servlet it generate a response that has a status of 500 with the xml 
document as the body of the response but instead of having text/xml as the 
content-type it will have text/html.

If I flush the Writer/OutputStream or flushBuffer the reponse the problem goes 
away.  The problem also goes away if the size of the response exceeds the 
response buffer size.

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
    response.setContentType("text/xml; charset=utf-8");
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

    String responseText = "<Document>Something bad has happened.</Document>";
    byte[] responseBytes = responseText.toBytes("utf-8");
    response.setContentLength(responseBytes.length);
    OutputStream os = response.getOutputStream();
    os.write(responseBytes);
}

What I would expect is that if a response body is written then it should be 
sent unaltered.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to