https://issues.apache.org/bugzilla/show_bug.cgi?id=46051

           Summary: Servlet response writer does not respect line.separator
                    system property
           Product: Tomcat 6
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=22763)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22763)
remove special CoyoteWriter println handling

public void doGet(final HttpServletRequest request, final HttpServletResponse
response) throws ServletException, IOException {
  response.setContentType("text/plain");
  PrintWriter writer = response.getWriter();
  writer.print("hello world");
  writer.println(); //FIXME ignores System.getProperty("line.separator") and
always outputs \r\n
  return;
}

This means that if you use a servlet Writer on a Unix system to output any text
based data format which is defined as requiring Unix format line endings
('\n'), that data will be corrupted.

This appears to be because org.apache.catalina.connector.CoyoteWriter does:
--------
private static final char[] LINE_SEP = { '\r', '\n' };

public void println() {
  write(LINE_SEP);
}
--------

This used to work in Tomcat 4.

Looking at the old code at
http://svn.apache.org/repos/asf/tomcat/archive/tc4.0.x/tags/tc4.0.6/connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteWriter.java
it appears to defer line endings to the PrintWriter base class which does the
right thing.

Was this change was made to output HTTP headers properly or something?  It
specifically seems to override the default behavior to do this.  I don't know
the code well enough to determine if the attached patch to revert to the
default behavior again would break something?

Thanks for your consideration.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

Reply via email to