cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java
markt 2004/08/25 13:44:15 Modified:coyote/src/java/org/apache/coyote Tag: TOMCAT_5_0 Request.java http11/src/java/org/apache/coyote/http11 Tag: TOMCAT_5_0 Http11Processor.java http11/src/java/org/apache/coyote/http11/filters Tag: TOMCAT_5_0 IdentityInputFilter.java util/java/org/apache/tomcat/util/buf Tag: TOMCAT_5_0 Ascii.java ByteChunk.java MessageBytes.java Log: Backport support for content-length greater than Integer.MAX_VALUE to 5.0.x branch Revision ChangesPath No revision No revision 1.27.2.1 +13 -10 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java Index: Request.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -r1.27 -r1.27.2.1 --- Request.java 24 Feb 2004 08:54:29 - 1.27 +++ Request.java 25 Aug 2004 20:44:15 - 1.27.2.1 @@ -134,10 +134,7 @@ /** * HTTP specific fields. (remove them ?) */ -private int contentLength = -1; -// how much body we still have to read. -// Apparently nobody uses this field... -private int available = -1; +private long contentLength = -1; private MessageBytes contentTypeMB = null; private String charEncoding = null; private Cookies cookies = new Cookies(headers); @@ -297,18 +294,25 @@ public void setContentLength(int len) { this.contentLength = len; - available = len; } public int getContentLength() { +long length = getContentLengthLong(); + +if (length Integer.MAX_VALUE) { +return (int) length; +} +return -1; +} + +public long getContentLengthLong() { if( contentLength -1 ) return contentLength; - MessageBytes clB = headers.getValue(content-length); -contentLength = (clB == null || clB.isNull()) ? -1 : clB.getInt(); - available = contentLength; +MessageBytes clB = headers.getValue(content-length); +contentLength = (clB == null || clB.isNull()) ? -1 : clB.getLong(); - return contentLength; +return contentLength; } @@ -424,7 +428,6 @@ throws IOException { int n = inputBuffer.doRead(chunk, this); if (n 0) { -available -= n; bytesRead+=n; } return n; No revision No revision 1.100.2.1 +1 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java Index: Http11Processor.java === RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v retrieving revision 1.100 retrieving revision 1.100.2.1 diff -u -r1.100 -r1.100.2.1 --- Http11Processor.java 1 Jun 2004 14:34:22 - 1.100 +++ Http11Processor.java 25 Aug 2004 20:44:15 - 1.100.2.1 @@ -1196,7 +1196,7 @@ InputFilter[] inputFilters = inputBuffer.getFilters(); // Parse content-length header -int contentLength = request.getContentLength(); +long contentLength = request.getContentLengthLong(); if (contentLength = 0) { inputBuffer.addActiveFilter (inputFilters[Constants.IDENTITY_FILTER]); No revision No revision 1.11.2.1 +1 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java Index: IdentityInputFilter.java === RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -r1.11 -r1.11.2.1 --- IdentityInputFilter.java 24 Feb 2004 08:50:55 - 1.11 +++ IdentityInputFilter.java 25 Aug 2004 20:44:15 - 1.11.2.1 @@ -144,7 +144,7 @@ * Read the content length from the request. */ public void setRequest(Request request) { -contentLength = request.getContentLength(); +contentLength = request.getContentLengthLong(); remaining = contentLength; } No revision No revision 1.2.2.1 +65 -0 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Ascii.java Index: Ascii.java
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java
markt 2004/08/12 14:46:41 Modified:coyote/src/java/org/apache/coyote Request.java http11/src/java/org/apache/coyote/http11 Http11Processor.java http11/src/java/org/apache/coyote/http11/filters IdentityInputFilter.java util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java Log: Fix bug 30152. Support content-length greater than Integer.MAX_VALUE. - Limit is now Long.MAX_VALUE - Only tested in simulation, not with a POST bigger than Integer.MAX_VALUE Revision ChangesPath 1.30 +11 -3 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java Index: Request.java === RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- Request.java 12 Aug 2004 19:48:05 - 1.29 +++ Request.java 12 Aug 2004 21:46:41 - 1.30 @@ -134,7 +134,7 @@ /** * HTTP specific fields. (remove them ?) */ -private int contentLength = -1; +private long contentLength = -1; private MessageBytes contentTypeMB = null; private String charEncoding = null; private Cookies cookies = new Cookies(headers); @@ -298,14 +298,22 @@ public int getContentLength() { +long length = getContentLengthLong(); + +if (length Integer.MAX_VALUE) { +return (int) length; +} +return -1; +} + +public long getContentLengthLong() { if( contentLength -1 ) return contentLength; MessageBytes clB = headers.getValue(content-length); -contentLength = (clB == null || clB.isNull()) ? -1 : clB.getInt(); +contentLength = (clB == null || clB.isNull()) ? -1 : clB.getLong(); return contentLength; } - public String getContentType() { contentType(); 1.103 +1 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java Index: Http11Processor.java === RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- Http11Processor.java 28 Jul 2004 18:52:17 - 1.102 +++ Http11Processor.java 12 Aug 2004 21:46:41 - 1.103 @@ -1196,7 +1196,7 @@ InputFilter[] inputFilters = inputBuffer.getFilters(); // Parse content-length header -int contentLength = request.getContentLength(); +long contentLength = request.getContentLengthLong(); if (contentLength = 0) { inputBuffer.addActiveFilter (inputFilters[Constants.IDENTITY_FILTER]); 1.12 +1 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java Index: IdentityInputFilter.java === RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- IdentityInputFilter.java 24 Feb 2004 08:50:55 - 1.11 +++ IdentityInputFilter.java 12 Aug 2004 21:46:41 - 1.12 @@ -144,7 +144,7 @@ * Read the content length from the request. */ public void setRequest(Request request) { -contentLength = request.getContentLength(); +contentLength = request.getContentLengthLong(); remaining = contentLength; } 1.4 +65 -0 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Ascii.java Index: Ascii.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Ascii.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Ascii.java12 Aug 2004 19:48:06 - 1.3 +++ Ascii.java12 Aug 2004 21:46:41 - 1.4 @@ -178,4 +178,69 @@ return n; } +/** + * Parses an unsigned long from the specified subarray of bytes. + * @param b the bytes to parse + * @param off the start offset of the bytes + * @param len the length of the bytes + * @exception NumberFormatException if the long format was invalid + */ +public static long parseLong(byte[] b, int off, int len) +throws NumberFormatException +{ +int c; + +if