cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java

2004-08-25 Thread markt
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

2004-08-12 Thread markt
markt   2004/08/12 12:48:06

  Modified:coyote/src/java/org/apache/coyote Request.java
   util/java/org/apache/tomcat/util/buf Ascii.java
  Log:
  Housekeeping before making some changes
   - Convert tabs to 8 spaces
   - Remove unused field
  
  Revision  ChangesPath
  1.29  +26 -32
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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Request.java  7 Jul 2004 16:29:34 -   1.28
  +++ Request.java  12 Aug 2004 19:48:05 -  1.29
  @@ -135,9 +135,6 @@
* 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 MessageBytes contentTypeMB = null;
   private String charEncoding = null;
   private Cookies cookies = new Cookies(headers);
  @@ -222,7 +219,7 @@
* Host: header.
*/
   public MessageBytes serverName() {
  - return serverNameMB;
  +return serverNameMB;
   }
   
   public int getServerPort() {
  @@ -230,31 +227,31 @@
   }
   
   public void setServerPort(int serverPort ) {
  - this.serverPort=serverPort;
  +this.serverPort=serverPort;
   }
   
   public MessageBytes remoteAddr() {
  - return remoteAddrMB;
  +return remoteAddrMB;
   }
   
   public MessageBytes remoteHost() {
  - return remoteHostMB;
  +return remoteHostMB;
   }
   
   public MessageBytes localName() {
  - return localNameMB;
  +return localNameMB;
   }
   
   public MessageBytes localAddr() {
  - return localAddrMB;
  +return localAddrMB;
   }
   
   public String getLocalHost() {
  - return localHost;
  +return localHost;
   }
   
   public void setLocalHost(String host) {
  - this.localHost = host;
  +this.localHost = host;
   }
   
   public int getRemotePort(){
  @@ -291,24 +288,22 @@
   
   
   public void setCharacterEncoding(String enc) {
  - this.charEncoding = enc;
  +this.charEncoding = enc;
   }
   
   
   public void setContentLength(int len) {
  - this.contentLength = len;
  - available = len;
  +this.contentLength = len;
   }
   
   
   public int getContentLength() {
   if( contentLength  -1 ) return contentLength;
   
  - MessageBytes clB = headers.getValue(content-length);
  +MessageBytes clB = headers.getValue(content-length);
   contentLength = (clB == null || clB.isNull()) ? -1 : clB.getInt();
  - available = contentLength;
   
  - return contentLength;
  +return contentLength;
   }
   
   
  @@ -369,7 +364,7 @@
   
   
   public Cookies getCookies() {
  - return cookies;
  +return cookies;
   }
   
   
  @@ -377,7 +372,7 @@
   
   
   public Parameters getParameters() {
  - return parameters;
  +return parameters;
   }
   
   
  @@ -424,7 +419,6 @@
   throws IOException {
   int n = inputBuffer.doRead(chunk, this);
   if (n  0) {
  -available -= n;
   bytesRead+=n;
   }
   return n;
  @@ -434,7 +428,7 @@
   //  debug 
   
   public String toString() {
  - return R(  + requestURI().toString() + );
  +return R(  + requestURI().toString() + );
   }
   
   public long getStartTime() {
  @@ -449,12 +443,12 @@
   
   
   public final void setNote(int pos, Object value) {
  - notes[pos] = value;
  +notes[pos] = value;
   }
   
   
   public final Object getNote(int pos) {
  - return notes[pos];
  +return notes[pos];
   }
   
   
  @@ -464,7 +458,7 @@
   public void recycle() {
   bytesRead=0;
   
  - contentLength = -1;
  +contentLength = -1;
   contentTypeMB = null;
   charEncoding = null;
   headers.recycle();
  @@ -473,21 +467,21 @@
   localPort = -1;
   remotePort = -1;
   
  - cookies.recycle();
  +cookies.recycle();
   parameters.recycle();
   
   unparsedURIMB.recycle();
   uriMB.recycle(); 
   decodedUriMB.recycle();
  - queryMB.recycle();
  - methodMB.recycle();
  - protoMB.recycle();
  - //remoteAddrMB.recycle();
  - //remoteHostMB.recycle();
  +queryMB.recycle();
  +methodMB.recycle();
  +protoMB.recycle();
  +//remoteAddrMB.recycle();
  +//remoteHostMB.recycle();
   
  - // XXX Do we need such defaults ?
 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java

2004-08-12 Thread markt
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