tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf Ascii.java ByteChunk.java MessageBytes.java
Date Wed, 25 Aug 2004 20:44:16 GMT
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  Changes    Path
  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 -0000	1.27
  +++ Request.java	25 Aug 2004 20:44:15 -0000	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 -0000	1.100
  +++ Http11Processor.java	25 Aug 2004 20:44:15 -0000	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 -0000	1.11
  +++ IdentityInputFilter.java	25 Aug 2004 20:44:15 -0000	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
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Ascii.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- Ascii.java	24 Feb 2004 08:50:06 -0000	1.2
  +++ Ascii.java	25 Aug 2004 20:44:15 -0000	1.2.2.1
  @@ -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 (b == null || len <= 0 || !isDigit(c = b[off++])) {
  +            throw new NumberFormatException();
  +        }
  +
  +        long n = c - '0';
  +        long m;
  +        
  +        while (--len > 0) {
  +            if (!isDigit(c = b[off++])) {
  +                throw new NumberFormatException();
  +            }
  +            m = n * 10 + c - '0';
  +
  +            if (m < n) {
  +                // Overflow
  +                throw new NumberFormatException();
  +            } else {
  +                n = m;
  +            }
  +        }
  +
  +        return n;
  +    }
  +
  +    public static long parseLong(char[] b, int off, int len)
  +        throws NumberFormatException
  +    {
  +        int c;
  +
  +        if (b == null || len <= 0 || !isDigit(c = b[off++])) {
  +            throw new NumberFormatException();
  +        }
  +
  +        long n = c - '0';
  +        long m;
  +
  +        while (--len > 0) {
  +            if (!isDigit(c = b[off++])) {
  +                throw new NumberFormatException();
  +            }
  +            m = n * 10 + c - '0';
  +
  +            if (m < n) {
  +                // Overflow
  +                throw new NumberFormatException();
  +            } else {
  +                n = m;
  +            }
  +        }
  +
  +        return n;
  +    }
  +
   }
  
  
  
  1.19.2.1  +5 -0      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.19
  retrieving revision 1.19.2.1
  diff -u -r1.19 -r1.19.2.1
  --- ByteChunk.java	8 Mar 2004 23:46:37 -0000	1.19
  +++ ByteChunk.java	25 Aug 2004 20:44:15 -0000	1.19.2.1
  @@ -477,6 +477,11 @@
   	return Ascii.parseInt(buff, start,end-start);
       }
   
  +    public long getLong() {
  +        return Ascii.parseLong(buff, start,end-start);
  +    }
  +
  +
       // -------------------- equals --------------------
   
       /**
  
  
  
  1.14.2.1  +24 -1     jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java
  
  Index: MessageBytes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- MessageBytes.java	28 Apr 2004 22:04:10 -0000	1.14
  +++ MessageBytes.java	25 Aug 2004 20:44:15 -0000	1.14.2.1
  @@ -113,6 +113,7 @@
   	hasStrValue=false;
   	hasHashCode=false;
   	hasIntValue=false;
  +    hasLongValue=false;
   	hasDateValue=false;	
       }
   
  @@ -504,11 +505,13 @@
       }
   
       // -------------------- Deprecated code --------------------
  -    // efficient int and date
  +    // efficient int, long and date
       // XXX used only for headers - shouldn't be
       // stored here.
       private int intValue;
       private boolean hasIntValue=false;
  +    private long longValue;
  +    private boolean hasLongValue=false;
       private Date dateValue;
       private boolean hasDateValue=false;
       
  @@ -617,6 +620,26 @@
   	return intValue;
       }
   
  +    // Used for headers conversion
  +    /** Convert the buffer to an long, cache the value
  +     */ 
  +    public long getLong() {
  +        if( hasLongValue )
  +            return longValue;
  +        
  +        switch (type) {
  +        case T_BYTES:
  +            longValue=byteC.getLong();
  +            break;
  +        default:
  +            longValue=Long.parseLong(toString());
  +        }
  +
  +        hasLongValue=true;
  +        return longValue;
  +
  +     }
  +   
       // -------------------- Future may be different --------------------
       
       private static MessageBytesFactory factory=new MessageBytesFactory();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message