tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 5322] New: - HttpResonseBase class sends headers with multiple field-values in a non HTTP compliant fashion.
Date Fri, 07 Dec 2001 19:52:42 GMT
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=5322>.
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=5322

HttpResonseBase class sends headers with multiple field-values in a non HTTP compliant fashion.

           Summary: HttpResonseBase class sends headers with multiple field-
                    values in a non HTTP compliant fashion.
           Product: Tomcat 4
           Version: 4.0.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: Ryan.Lubke@Sun.COM


Currently, if a servlet executes the following:

response.addIntHeader( "MyIntHeader", 2 );
response.addIntHeader( "MyIntHeader", 3 );

The response stream from the server will contain the following headers:
MyIntHeader: 2
MyIntHeader: 3

The above behavior appears to be inconsistent against what the HTTP 1.0 and 1.1
RFC's state (Section 4.2 Message Headers):

"Multiple HTTP_header fields with the same field-name may be present in a
message if and only if the entire field-value for that header field is defined
as a comma-separated list [i.e, #(values)].  It must be possible to combine
the multiple header fields into on "field-name: field-value" pair, without
changing the semantics of the message, by appending each sebsequent field-value
to the first, each separated by a comma".

I've include a patch that seems to resolve this in my env.  Several header tests
that I have run just fine with the patch applied.

************************************************************************
Index: HttpResponseBase.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
retrieving revision 1.41
diff -u -r1.41 HttpResponseBase.java
--- HttpResponseBase.java   2001/12/03 19:55:04 1.41
+++ HttpResponseBase.java   2001/12/07 18:15:46
@@ -597,19 +597,22 @@

         // Send all specified headers (if any)
         synchronized (headers) {
-        Iterator names = headers.keySet().iterator();
-        while (names.hasNext()) {
-            String name = (String) names.next();
-            ArrayList values = (ArrayList) headers.get(name);
-            Iterator items = values.iterator();
-            while (items.hasNext()) {
-                String value = (String) items.next();
-                    outputWriter.print(name);
-                    outputWriter.print(": ");
+            Iterator names = headers.keySet().iterator();
+            while (names.hasNext()) {
+                String name = (String) names.next();
+                ArrayList values = (ArrayList) headers.get(name);
+                Iterator items = values.iterator();
+                outputWriter.print(name);
+                outputWriter.print(": ");
+                while (items.hasNext()) {
+                    String value = (String) items.next();
                     outputWriter.print(value);
-                    outputWriter.print("\r\n");
-                    // System.out.println(" " + name + ": " + value);
+                    if ( items.hasNext() ) {
+                        outputWriter.print(",");
+                    }
                 }
+                outputWriter.print("\r\n");
+                // System.out.println(" " + name + ": " + value);
             }
         }

******************************************************************************

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message