You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/05/31 20:56:16 UTC

cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core StandardWrapperValve.java WrappedRequest.java

craigmcc    00/05/31 11:56:14

  Modified:    proposals/catalina/src/conf server.xml
               proposals/catalina/src/share/org/apache/tomcat Request.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        RequestBase.java ResponseBase.java
               proposals/catalina/src/share/org/apache/tomcat/connector/test
                        HttpProcessor.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        StandardWrapperValve.java WrappedRequest.java
  Log:
  Switch back to the "test" HTTP connector as the default.  (Remy, I was
  encountering problems where the server left the socket open even though
  my browser was sending HTTP/1.0 requests.)
  
  Add Request.finishRequest() to complement Response.finishResponse(), and
  update the default implementations of Request to include this method.
  
  Move responsibility for calling finishRequest() and finishResponse() from
  the servlet wrapper (StandardWrapperValve) to the connector (in the case
  of the test connector, actually in HttpProcessor).  Otherwise, Valves that
  created a response themselves and then returned would not benefit from the
  calls to the "finish" methods.
  
  Revision  Changes    Path
  1.33      +5 -0      jakarta-tomcat/proposals/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- server.xml	2000/05/31 03:06:10	1.32
  +++ server.xml	2000/05/31 18:55:55	1.33
  @@ -6,7 +6,12 @@
   
     <!-- Define all the connectors to associate with the following container -->
   
  +<!--
     <Connector className="org.apache.tomcat.connector.http.HttpConnector"
  +             port="8080" minProcessors="5" maxProcessors="75"
  +	     acceptCount="10" debug="0"/>
  +-->
  +  <Connector className="org.apache.tomcat.connector.test.HttpConnector"
                port="8080" minProcessors="5" maxProcessors="75"
   	     acceptCount="10" debug="0"/>
   
  
  
  
  1.7       +13 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Request.java	2000/05/05 18:25:05	1.6
  +++ Request.java	2000/05/31 18:55:57	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v 1.6 2000/05/05 18:25:05 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/05/05 18:25:05 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v 1.7 2000/05/31 18:55:57 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/05/31 18:55:57 $
    *
    * ====================================================================
    *
  @@ -78,7 +78,7 @@
    * produce the corresponding <code>Response</code>.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/05/05 18:25:05 $
  + * @version $Revision: 1.7 $ $Date: 2000/05/31 18:55:57 $
    */
   
   public interface Request {
  @@ -201,6 +201,15 @@
        * @exception IOException if an input/output error occurs
        */
       public ServletInputStream createInputStream() throws IOException;
  +
  +
  +    /**
  +     * Perform whatever actions are required to flush and close the input
  +     * stream or reader, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishRequest() throws IOException;
   
   
       /**
  
  
  
  1.11      +36 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java
  
  Index: RequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RequestBase.java	2000/05/30 21:29:43	1.10
  +++ RequestBase.java	2000/05/31 18:56:00	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v 1.10 2000/05/30 21:29:43 craigmcc Exp $
  - * $Revision: 1.10 $
  - * $Date: 2000/05/30 21:29:43 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v 1.11 2000/05/31 18:56:00 craigmcc Exp $
  + * $Revision: 1.11 $
  + * $Date: 2000/05/31 18:56:00 $
    *
    * ====================================================================
    *
  @@ -94,7 +94,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.10 $ $Date: 2000/05/30 21:29:43 $
  + * @version $Revision: 1.11 $ $Date: 2000/05/31 18:56:00 $
    */
   
   public abstract class RequestBase
  @@ -423,6 +423,38 @@
       public ServletInputStream createInputStream() throws IOException {
   
   	return (new RequestStream(this));
  +
  +    }
  +
  +
  +    /**
  +     * Perform whatever actions are required to flush and close the input
  +     * stream or reader, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishRequest() throws IOException {
  +
  +	// If a Reader has been acquired, close it
  +	if (reader != null) {
  +	    try {
  +		reader.close();
  +	    } catch (IOException e) {
  +		;
  +	    }
  +	}
  +
  +	// If a ServletInputStream has been acquired, close it
  +	if (stream != null) {
  +	    try {
  +		stream.close();
  +	    } catch (IOException e) {
  +		;
  +	    }
  +	}
  +
  +	// The underlying input stream (perhaps from a socket)
  +	// is not our responsibility
   
       }
   
  
  
  
  1.12      +7 -4      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java
  
  Index: ResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ResponseBase.java	2000/05/30 21:29:43	1.11
  +++ ResponseBase.java	2000/05/31 18:56:01	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v 1.11 2000/05/30 21:29:43 craigmcc Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/05/30 21:29:43 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v 1.12 2000/05/31 18:56:01 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/05/31 18:56:01 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/05/30 21:29:43 $
  + * @version $Revision: 1.12 $ $Date: 2000/05/31 18:56:01 $
    */
   
   public abstract class ResponseBase
  @@ -366,6 +366,9 @@
   	    stream.flush();
   	    stream.close();
   	}
  +
  +	// The underlying output stream (perhaps from a socket)
  +	// is not our responsibility
   
       }
   
  
  
  
  1.13      +24 -8     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HttpProcessor.java	2000/05/30 21:29:47	1.12
  +++ HttpProcessor.java	2000/05/31 18:56:07	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v 1.12 2000/05/30 21:29:47 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/05/30 21:29:47 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/test/HttpProcessor.java,v 1.13 2000/05/31 18:56:07 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/05/31 18:56:07 $
    *
    * ====================================================================
    *
  @@ -103,7 +103,7 @@
    * the request.  When the processor is completed, it will recycle itself.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.12 $ $Date: 2000/05/30 21:29:47 $
  + * @version $Revision: 1.13 $ $Date: 2000/05/31 18:56:07 $
    */
   
   final class HttpProcessor
  @@ -652,12 +652,12 @@
   	    ok = false;
   	}
   
  -	// Finish up the handling of the request
  +	// Finish up the handling of the response
   	try {
  -	    if (input != null)
  -	        input.close();
  +	    if (ok)
  +		response.finishResponse();
   	} catch (IOException e) {
  -	    log("FIXME-Exception closing input", e);
  +	    log("FIXME-Exception from finishResponse", e);
   	}
   	try {
   	    if (output != null)
  @@ -671,6 +671,22 @@
   	} catch (IOException e) {
   	    log("FIXME-Exception closing output", e);
   	}
  +
  +	// Finish up the handling of the request
  +	try {
  +	    if (ok)
  +		request.finishRequest();
  +	} catch (IOException e) {
  +	    log("FIXME-Exception from finishRequest", e);
  +	}
  +	try {
  +	    if (input != null)
  +	        input.close();
  +	} catch (IOException e) {
  +	    log("FIXME-Exception closing input", e);
  +	}
  +
  +	// Finish up the handling of the socket connection itself
   	try {
   	    socket.close();
   	} catch (IOException e) {
  
  
  
  1.12      +4 -7      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StandardWrapperValve.java	2000/05/31 01:33:30	1.11
  +++ StandardWrapperValve.java	2000/05/31 18:56:09	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v 1.11 2000/05/31 01:33:30 remm Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/05/31 01:33:30 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v 1.12 2000/05/31 18:56:09 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/05/31 18:56:09 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * <code>StandardWrapper</code> container implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/05/31 01:33:30 $
  + * @version $Revision: 1.12 $ $Date: 2000/05/31 18:56:09 $
    */
   
   final class StandardWrapperValve
  @@ -233,9 +233,6 @@
   	if (throwable == null) {
   	    status(request, response);
   	}
  -
  -	// Finish flushing the output buffer as necessary
  -	response.finishResponse();
   
       }
   
  
  
  
  1.3       +17 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/WrappedRequest.java
  
  Index: WrappedRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/WrappedRequest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WrappedRequest.java	2000/05/05 18:25:10	1.2
  +++ WrappedRequest.java	2000/05/31 18:56:11	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/WrappedRequest.java,v 1.2 2000/05/05 18:25:10 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/05/05 18:25:10 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/WrappedRequest.java,v 1.3 2000/05/31 18:56:11 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/05/31 18:56:11 $
    *
    * ====================================================================
    *
  @@ -103,7 +103,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/05/05 18:25:10 $
  + * @version $Revision: 1.3 $ $Date: 2000/05/31 18:56:11 $
    */
   
   final class WrappedRequest
  @@ -781,6 +781,19 @@
        */
       public ServletInputStream createInputStream() throws IOException {
   	return (request.createInputStream());
  +    }
  +
  +
  +    /**
  +     * Perform whatever actions are required to flush and close the input
  +     * stream or reader, in a single operation.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public void finishRequest() throws IOException {
  +
  +	request.finishRequest();
  +
       }