You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/04/22 18:09:32 UTC

DO NOT REPLY [Bug 7754] - Response Folded Headers throws HttpException

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=7754>.
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=7754

Response Folded Headers throws HttpException





------- Additional Comments From ericv@kinzan.com  2002-04-22 16:09 -------
Index: 
HttpMethodBase.java
===================================================================
RCS 
file: /home/cvspublic/jakarta-
commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving 
revision 1.28
diff -u -b -r1.28 HttpMethodBase.java
--- HttpMethodBase.java	16 Apr 2002 
14:30:42 -0000	1.28
+++ HttpMethodBase.java	19 Apr 2002 19:49:40 -0000
@@ -1032,6 +1032,8 
@@
         }
         responseHeaders.clear();
 
+        String name = null;
+        String value = null;
         for(;;) 
{
             String line = conn.readLine();
             if ((line == null) || (line.length() < 1)) {
@@ -1039,20 
+1041,42 @@
             }
 
             // Parse the header name and value
+            // Check for folded headers first
+            // 
Detect LWS-char see HTTP/1.0 or HTTP/1.1 Section 2.2 
+            // discussion on folded headers
+            
boolean isFolded = false;
+            if ( line.charAt(0) == ' ' || line.charAt(0) == '\t' )
+            {
+                // we 
have continuation folded header
+                // so append value
+                isFolded = true;
+                value = 
line.substring(1).trim();
+            }
+            else
+            {
+                // Otherwise we should have normal HTTP header 
line
             int colon = line.indexOf(":");
             if (colon < 0) {
                 throw new HttpException("Unable to 
parse header: " + line);
             }
-            String name = line.substring(0, colon).trim();
+                name = 
line.substring(0, colon).trim();
+                value = line.substring(colon + 1).trim();
+            }
             
String match = name.toLowerCase();
-            String value = line.substring(colon + 1).trim();
             
Header header = (Header)(responseHeaders.get(match));
             if (null == header) {
                 header = new 
Header(name, value);
             } else {
                 String oldvalue =  header.getValue();
                 if (null != oldvalue) 
{
+                    if ( isFolded ) {
+                        // LWS becomes space plus extended value
+                        header = new 
Header(name,oldvalue + " " + value);
+                    }
+                    else {
+                        // Append additional header value
                     
header = new Header(name,oldvalue + ", " + value);
+                    }
                 } else {
                     header = new 
Header(name,value);
                 }

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>