tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java
Date Sat, 22 Sep 2001 22:05:31 GMT
costin      01/09/22 15:05:31

  Modified:    src/share/org/apache/tomcat/modules/server
                        Http10Interceptor.java
  Log:
  Fix for 3745 - thanks Stefan Eissing for finding the bug.
  
  doRead() should return -1 on end of stream, and available should be used
  only if is known ( -1 means unknown length, read until EOF ).
  
  Revision  Changes    Path
  1.25      +14 -5     jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Http10Interceptor.java	2001/09/21 08:29:56	1.24
  +++ Http10Interceptor.java	2001/09/22 22:05:31	1.25
  @@ -232,17 +232,26 @@
       }
   
       public int doRead() throws IOException {
  -	if( available <= 0 )
  +	if( available == 0 ) 
   	    return -1;
  -	available--;
  +	// #3745
  +	// if available == -1: unknown length, we'll read until end of stream.
  +	if( available!= -1 )
  +	    available--;
   	return http.doRead();
       }
   
       public int doRead(byte[] b, int off, int len) throws IOException {
  -	if( available <= 0 )
  -	    return 0;
  +	if( available == 0 )
  +	    return -1;
  +	// if available == -1: unknown length, we'll read until end of stream.
   	int rd=http.doRead( b, off, len );
  -	available -= rd;
  +	if( rd==-1) {
  +	    available=0;
  +	    return -1;
  +	}
  +	if( available!= -1 )
  +	    available -= rd;
   	return rd;
       }
       
  
  
  

Mime
View raw message