Author: markt Date: Sat Mar 3 07:56:14 2007 New Revision: 514176 URL: http://svn.apache.org/viewvc?view=rev&rev=514176 Log: Port fix from TC5. As per RFC2616, requests with multiple content-length headers are invalid.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/Request.java tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/Request.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/Request.java?view=diff&rev=514176&r1=514175&r2=514176 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/Request.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/Request.java Sat Mar 3 07:56:14 2007 @@ -294,7 +294,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/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java?view=diff&rev=514176&r1=514175&r2=514176 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java Sat Mar 3 07:56:14 2007 @@ -293,6 +293,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]