costin      01/08/25 18:52:18

  Modified:    src/share/org/apache/tomcat/core Response.java
  Log:
  Fix for bug 1920.
  
  Thanks to [EMAIL PROTECTED] (Eddie Ruvinsky) for reporting the bug.
  
  There is no need to keep the duplicated 'int contentLength' ( it's just an
  useless overhead ), and it brakes 'long' lengths.
  
  Revision  Changes    Path
  1.55      +23 -16    jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- Response.java     2001/08/17 04:02:54     1.54
  +++ Response.java     2001/08/26 01:52:18     1.55
  @@ -117,7 +117,6 @@
       protected String contentType = DEFAULT_CONTENT_TYPE;
       protected String contentLanguage = null;
       protected String characterEncoding = DEFAULT_CHAR_ENCODING;
  -    protected int contentLength = -1;
       protected Locale locale = DEFAULT_LOCALE;
   
       // -------------------- Constructor --------------------
  @@ -252,7 +251,6 @@
            contentType = DEFAULT_CONTENT_TYPE;
            locale = DEFAULT_LOCALE;
            characterEncoding = DEFAULT_CHAR_ENCODING;
  -         contentLength = -1;
            status = 200;
            headers.clear();
        }
  @@ -317,17 +315,17 @@
            setContentType( value );
            return true;
        }
  -     if( name.equalsIgnoreCase( "Content-Length" ) ) {
  -         try {
  -             int cL=Integer.parseInt( value );
  -             setContentLength( cL );
  -             return true;
  -         } catch( NumberFormatException ex ) {
  -             // Do nothing - the spec doesn't have any "throws" 
  -             // and the user might know what he's doing
  -             return false;
  -         }
  -     }
  +//   if( name.equalsIgnoreCase( "Content-Length" ) ) {
  +//       try {
  +//           int cL=Integer.parseInt( value );
  +//           setContentLength( cL );
  +//           return true;
  +//       } catch( NumberFormatException ex ) {
  +//           // Do nothing - the spec doesn't have any "throws" 
  +//           // and the user might know what he's doing
  +//           return false;
  +//       }
  +//   }
        if( name.equalsIgnoreCase( "Content-Language" ) ) {
            // XXX XXX Need to construct Locale or something else
        }
  @@ -460,12 +458,22 @@
       
       public void setContentLength(int contentLength) {
           if( included ) return;
  -     this.contentLength = contentLength;
        headers.setValue("Content-Length").setInt(contentLength);
       }
   
  +    /** @deprecated. Not used in any piece of code, will fail for long values,
  +     it's not an acurate value of the length ( just the header ).
  +    */
       public int getContentLength() {
  -     return contentLength;
  +     String value=headers.getHeader( "Content-Length" );
  +     if( value == null )
  +         return -1;
  +     try {
  +         int cL=Integer.parseInt( value );
  +         return cL;
  +     } catch( Exception ex ) {
  +         return -1;
  +     }
       }
   
       // -------------------- Extend --------------------
  @@ -490,7 +498,6 @@
        contentLanguage = null;
           locale = DEFAULT_LOCALE;
        characterEncoding = DEFAULT_CHAR_ENCODING;
  -     contentLength = -1;
        status = 200;
        usingWriter = false;
        usingStream = false;
  
  
  

Reply via email to