Author: jfclere
Date: Tue Apr 24 00:16:14 2007
New Revision: 531795

URL: http://svn.apache.org/viewvc?view=rev&rev=531795
Log:
As per RFC2616, requests with multiple content-length headers are invalid.
Ported from tc5.5.x

Modified:
    
tomcat/connectors/branches/tc5.0.x/coyote/src/java/org/apache/coyote/Request.java
    
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/MimeHeaders.java

Modified: 
tomcat/connectors/branches/tc5.0.x/coyote/src/java/org/apache/coyote/Request.java
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/branches/tc5.0.x/coyote/src/java/org/apache/coyote/Request.java?view=diff&rev=531795&r1=531794&r2=531795
==============================================================================
--- 
tomcat/connectors/branches/tc5.0.x/coyote/src/java/org/apache/coyote/Request.java
 (original)
+++ 
tomcat/connectors/branches/tc5.0.x/coyote/src/java/org/apache/coyote/Request.java
 Tue Apr 24 00:16:14 2007
@@ -308,7 +308,7 @@
     public long getContentLengthLong() {
         if( contentLength > -1 ) return contentLength;
 
-        MessageBytes clB = headers.getValue("content-length");
+        MessageBytes clB = headers.getUniqueValue("content-length");
         contentLength = (clB == null || clB.isNull()) ? -1 : clB.getLong();
 
         return contentLength;

Modified: 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/MimeHeaders.java
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/MimeHeaders.java?view=diff&rev=531795&r1=531794&r2=531795
==============================================================================
--- 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/MimeHeaders.java
 (original)
+++ 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/MimeHeaders.java
 Tue Apr 24 00:16:14 2007
@@ -286,6 +286,25 @@
         return null;
     }
 
+    /**
+     * Finds and returns a unique header field with the given name. If no such
+     * field exists, null is returned. If the specified header field is not
+     * unique then an [EMAIL PROTECTED] IllegalArgumentException} is thrown.
+     */
+    public MessageBytes getUniqueValue(String name) {
+        MessageBytes result = null;
+        for (int i = 0; i < count; i++) {
+            if (headers[i].getName().equalsIgnoreCase(name)) {
+                if (result == null) {
+                    result = headers[i].getValue();
+                } else {
+                    throw new IllegalArgumentException();
+                }
+            }
+        }
+        return result;
+    }
+
     // bad shortcut - it'll convert to string ( too early probably,
     // encoding is guessed very late )
     public String getHeader(String name) {



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

Reply via email to