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=11647>. 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=11647 Encoding of Response Headers Violates HTTP Spec. Summary: Encoding of Response Headers Violates HTTP Spec. Product: Tomcat 4 Version: 4.1.8 Platform: All OS/Version: All Status: UNCONFIRMED Severity: Normal Priority: Other Component: Unknown AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hello, I'm using Tomcat v4.1.8 on Win 2k, SP3. My client (i.e., browswer) is running on a separate Win 2k, SP3 machine. I've tested this issue with IE 6 and Navigator 6.2. I've also used the Wild Packets sniffer to see what bytes Tomcat was sending. Here's the problem: If a servlet sets the charset within the "Content-Type" response header (e.g., "text/html;charset=UTF-16"), the response headers will be encoded according to the specified encoding, rather than US-ASCII as specified by RFC 2616 (http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc2616.html). Below is a simple servlet that shows the problem. The servlet below specifies an encoding of UTF-16. The PrintWriter correctly encodes the response body as UTF-16. The problem is that the response *headers* are also being encoded as UTF-16, which violates the HTTP spec (see Section 2.2). The headers should be encoded as US-ASCII (or US-ASCII "compatible"). I know it's possible to use UTF-8 or some other US-ASCII "compatible" encoding where the first 127 characters are encoded the same as US-ASCII -- I realize that's a possible "work around". IMHO, however, Tomcat should encode headers according to the spec, regardless of how the response body is encoded. This is the first time I've submitted a Tomcat bug. Can you tell me if there is a way for me to check the status? Thanks. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Tester extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-16"); PrintWriter pw = response.getWriter(); pw.println("<html><head><title>Test</title></head>" + "<body><p>AAAA BBBB CCCC</p></body></html>"); } // doGet() } // Tester -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>