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 MessageBytes.java
Date Fri, 10 Dec 2004 00:00:00 GMT
markt       2004/12/09 16:00:00

  Modified:    coyote/src/java/org/apache/coyote Response.java
               http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
               http11/src/java/org/apache/coyote/http11/filters
                        IdentityOutputFilter.java
               util/java/org/apache/tomcat/util/buf MessageBytes.java
  Log:
  Fix bug 32585. Better handling for content length greater than
    Integer.MAX_VALUE in response.
  
  Revision  Changes    Path
  1.35      +10 -1     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Response.java	28 Jul 2004 18:51:44 -0000	1.34
  +++ Response.java	10 Dec 2004 00:00:00 -0000	1.35
  @@ -100,7 +100,7 @@
       protected String contentType = null;
       protected String contentLanguage = null;
       protected String characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
  -    protected int contentLength = -1;
  +    protected long contentLength = -1;
       private Locale locale = DEFAULT_LOCALE;
   
       // General informations
  @@ -529,6 +529,15 @@
       }
   
       public int getContentLength() {
  +        long length = getContentLengthLong();
  +        
  +        if (length < Integer.MAX_VALUE) {
  +            return (int) length;
  +        }
  +        return -1;
  +    }
  +    
  +    public long getContentLengthLong() {
           return contentLength;
       }
   
  
  
  
  1.116     +2 -2      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.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- Http11Processor.java	22 Nov 2004 06:42:46 -0000	1.115
  +++ Http11Processor.java	10 Dec 2004 00:00:00 -0000	1.116
  @@ -1489,9 +1489,9 @@
               }
           }
   
  -        int contentLength = response.getContentLength();
  +        long contentLength = response.getContentLengthLong();
           if (contentLength != -1) {
  -            headers.setValue("Content-Length").setInt(contentLength);
  +            headers.setValue("Content-Length").setLong(contentLength);
               outputBuffer.addActiveFilter
                   (outputFilters[Constants.IDENTITY_FILTER]);
               contentDelimitation = true;
  
  
  
  1.8       +1 -1      jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java
  
  Index: IdentityOutputFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- IdentityOutputFilter.java	24 Feb 2004 08:50:55 -0000	1.7
  +++ IdentityOutputFilter.java	10 Dec 2004 00:00:00 -0000	1.8
  @@ -141,7 +141,7 @@
        * after the response header processing is complete.
        */
       public void setResponse(Response response) {
  -        contentLength = response.getContentLength();
  +        contentLength = response.getContentLengthLong();
           remaining = contentLength;
       }
   
  
  
  
  1.21      +42 -0     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MessageBytes.java	12 Nov 2004 10:51:49 -0000	1.20
  +++ MessageBytes.java	10 Dec 2004 00:00:00 -0000	1.21
  @@ -610,6 +610,48 @@
           type=T_BYTES;
       }
   
  +    /** Set the buffer to the representation of an long
  +     */
  +    public void setLong(long l) {
  +        byteC.allocate(32, 64);
  +        long current = l;
  +        byte[] buf = byteC.getBuffer();
  +        int start = 0;
  +        int end = 0;
  +        if (l == 0) {
  +            buf[end++] = (byte) '0';
  +        }
  +        if (l < 0) {
  +            current = -l;
  +            buf[end++] = (byte) '-';
  +        }
  +        while (current > 0) {
  +            int digit = (int) (current % 10);
  +            current = current / 10;
  +            buf[end++] = HexUtils.HEX[digit];
  +        }
  +        byteC.setOffset(0);
  +        byteC.setEnd(end);
  +        // Inverting buffer
  +        end--;
  +        if (l < 0) {
  +            start++;
  +        }
  +        while (end > start) {
  +            byte temp = buf[start];
  +            buf[start] = buf[end];
  +            buf[end] = temp;
  +            start++;
  +            end--;
  +        }
  +        longValue=l;
  +        hasStrValue=false;
  +        hasHashCode=false;
  +        hasIntValue=false;
  +        hasLongValue=true;
  +        hasDateValue=false; 
  +        type=T_BYTES;
  +    }
   
       /**
        *  @deprecated The buffer are general purpose, caching for headers should
  
  
  

---------------------------------------------------------------------
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