tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets DefaultServlet.java
Date Mon, 05 Jun 2000 16:22:02 GMT
remm        00/06/05 09:22:01

  Modified:    proposals/catalina/src/share/org/apache/tomcat/servlets
                        DefaultServlet.java
  Log:
  Added back the code for serving static files when responding to a
  non-ranged request (it is faster)
  
  Revision  Changes    Path
  1.7       +37 -5     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultServlet.java	2000/06/04 23:18:48	1.6
  +++ DefaultServlet.java	2000/06/05 16:22:00	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.6 2000/06/04 23:18:48 remm Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/06/04 23:18:48 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.7 2000/06/05 16:22:00 remm Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/06/05 16:22:00 $
    *
    * ====================================================================
    *
  @@ -101,7 +101,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.6 $ $Date: 2000/06/04 23:18:48 $
  + * @version $Revision: 1.7 $ $Date: 2000/06/05 16:22:00 $
    */
   
   public final class DefaultServlet
  @@ -312,7 +312,7 @@
   	// Copy the input stream to the output stream
   	IOException exception = null;
           if (file.length() > 0)
  -            exception = copyRange(istream, ostream, 0, file.length() - 1);
  +            exception = copyRange(istream, ostream);
           
   	// Clean up the input and output streams
   	try {
  @@ -446,6 +446,38 @@
   	// Rethrow any exception that has occurred
   	if (exception != null)
   	    throw exception;
  +        
  +    }
  +
  +
  +    /**
  +     * Copy the contents of the specified input stream to the specified
  +     * output stream, and ensure that both streams are closed before returning
  +     * (even in the face of an exception).
  +     *
  +     * @param istream The input stream to read from
  +     * @param ostream The output stream to write to
  +     * @return Exception which occured during processing
  +     */
  +    private IOException copyRange(InputStream istream, 
  +                                  ServletOutputStream ostream) {
  +        
  +	// Copy the input stream to the output stream
  +	IOException exception = null;
  +	byte buffer[] = new byte[input];
  +	int len = buffer.length;
  +	while (len >= buffer.length) {
  +	    try {
  +		len = istream.read(buffer);
  +		ostream.write(buffer, 0, len);
  +	    } catch (IOException e) {
  +		exception = e;
  +		len = -1;
  +	    }
  +	    if (len < buffer.length)
  +		break;
  +	}
  +        return exception;
           
       }
   
  
  
  

Mime
View raw message