remm        02/01/09 04:57:49

  Modified:    http11/src/java/org/apache/coyote/http11 Constants.java
                        Http11Connector.java InternalInputBuffer.java
                        InternalOutputBuffer.java
  Added:       http11/src/java/org/apache/coyote/http11/filters
                        VoidInputFilter.java
  Log:
  - Call recycle on the request and response objects when appropriate.
  - Add a VoidInputFilter which will be used with GET and HEAD methods.
  
  Revision  Changes    Path
  1.4       +6 -0      
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Constants.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Constants.java    9 Dec 2001 22:10:47 -0000       1.3
  +++ Constants.java    9 Jan 2002 12:57:49 -0000       1.4
  @@ -156,6 +156,12 @@
   
   
       /**
  +     * Void filters (input and output).
  +     */
  +    public static final int VOID_FILTER = 2;
  +
  +
  +    /**
        * HTTP/1.0.
        */
       public static final String HTTP_10 = "HTTP/1.0";
  
  
  
  1.7       +14 -3     
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Connector.java
  
  Index: Http11Connector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Connector.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Http11Connector.java      1 Jan 2002 21:34:01 -0000       1.6
  +++ Http11Connector.java      9 Jan 2002 12:57:49 -0000       1.7
  @@ -82,6 +82,7 @@
   import org.apache.coyote.http11.filters.ChunkedOutputFilter;
   import org.apache.coyote.http11.filters.IdentityInputFilter;
   import org.apache.coyote.http11.filters.IdentityOutputFilter;
  +import org.apache.coyote.http11.filters.VoidInputFilter;
   import org.apache.coyote.http11.filters.VoidOutputFilter;
   
   
  @@ -264,12 +265,15 @@
                   
                   inputBuffer.parseHeaders();
               } catch (EOFException e) {
  +                e.printStackTrace();
                   error = true;
                   break;
               } catch (InterruptedIOException e) {
  +                e.printStackTrace();
                   //HttpServletResponse.SC_BAD_REQUEST
                   error = true;
               } catch (Exception e) {
  +                e.printStackTrace();
                   //SC_BAD_REQUEST
                   error = true;
               }
  @@ -281,6 +285,7 @@
               try {
                   adapter.service(request, response);
               } catch (InterruptedIOException e) {
  +                e.printStackTrace();
                   error = true;
               } catch (Throwable t) {
                   // ISE
  @@ -292,6 +297,7 @@
               try {
                   outputBuffer.endRequest();
               } catch (IOException e) {
  +                e.printStackTrace();
                   error = true;
               } catch (Throwable t) {
                   // Problem ...
  @@ -299,11 +305,15 @@
                   error = true;
               }
   
  -            // FIXME: Next request
  +            // Next request
  +            inputBuffer.nextRequest();
  +            outputBuffer.nextRequest();
   
           }
   
  -        // FIXME: Recycle
  +        // Recycle
  +        inputBuffer.recycle();
  +        outputBuffer.recycle();
   
       }
   
  @@ -552,7 +562,8 @@
           inputBuffer.addFilter(new ChunkedInputFilter());
           outputBuffer.addFilter(new ChunkedOutputFilter());
   
  -        // Create and add the void filter.
  +        // Create and add the void filters.
  +        inputBuffer.addFilter(new VoidInputFilter());
           outputBuffer.addFilter(new VoidOutputFilter());
   
       }
  
  
  
  1.7       +8 -5      
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java
  
  Index: InternalInputBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InternalInputBuffer.java  8 Jan 2002 16:03:34 -0000       1.6
  +++ InternalInputBuffer.java  9 Jan 2002 12:57:49 -0000       1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v
 1.6 2002/01/08 16:03:34 remm Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/08 16:03:34 $
  + * $Header: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v
 1.7 2002/01/09 12:57:49 remm Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/09 12:57:49 $
    *
    * ====================================================================
    *
  @@ -116,6 +116,7 @@
   
           filterLibrary = new InputFilter[0];
           activeFilters = new InputFilter[0];
  +        lastActiveFilter = -1;
   
           parsingHeader = true;
   
  @@ -314,7 +315,8 @@
        */
       public void recycle() {
   
  -        // FIXME: Recycle Request object (or do it elsewhere) ?
  +        // Recycle Request object
  +        request.recycle();
   
           inputStream = null;
           buf = headerBuffer1;
  @@ -335,7 +337,8 @@
       public void nextRequest()
           throws IOException {
   
  -        // FIXME: Recycle Request object (or do it elsewhere) ?
  +        // Recycle Request object
  +        request.recycle();
   
           // Determine the header buffer used for next request
           byte[] newHeaderBuf = null;
  
  
  
  1.7       +4 -2      
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java
  
  Index: InternalOutputBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InternalOutputBuffer.java 1 Jan 2002 21:34:01 -0000       1.6
  +++ InternalOutputBuffer.java 9 Jan 2002 12:57:49 -0000       1.7
  @@ -290,7 +290,8 @@
        */
       public void recycle() {
   
  -        // FIXME: Recycle Request object (or do it elsewhere) ?
  +        // Recycle Request object
  +        response.recycle();
   
           outputStream = null;
           buf = headerBuffer;
  @@ -309,7 +310,8 @@
        */
       public void nextRequest() {
   
  -        // FIXME: Recycle Response object (or do it elsewhere) ?
  +        // Recycle Request object
  +        response.recycle();
   
           // Determine the header buffer used for next request
           buf = headerBuffer;
  
  
  
  1.1                  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/VoidInputFilter.java
  
  Index: VoidInputFilter.java
  ===================================================================
  /*
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.coyote.http11.filters;
  
  import java.io.IOException;
  
  import org.apache.tomcat.util.buf.ByteChunk;
  
  import org.apache.coyote.InputBuffer;
  import org.apache.coyote.Request;
  import org.apache.coyote.http11.InputFilter;
  
  /**
   * Void input filter, which returns -1 when attempting a read. Used with a GET,
   * HEAD, or a similar request.
   * 
   * @author Remy Maucherat
   */
  public class VoidInputFilter implements InputFilter {
  
  
      // -------------------------------------------------------------- Constants
  
  
      protected static final String ENCODING_NAME = "void";
      protected static final ByteChunk ENCODING = new ByteChunk();
  
  
      // ----------------------------------------------------- Static Initializer
  
  
      static {
          ENCODING.setBytes(ENCODING_NAME.getBytes(), 0, ENCODING_NAME.length());
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // --------------------------------------------------- OutputBuffer Methods
  
  
      /**
       * Write some bytes.
       * 
       * @return number of bytes written by the filter
       */
      public int doRead(ByteChunk chunk)
          throws IOException {
  
          return -1;
  
      }
  
  
      // --------------------------------------------------- OutputFilter Methods
  
  
      /**
       * Set the associated reauest.
       */
      public void setRequest(Request request) {
      }
  
  
      /**
       * Set the next buffer in the filter pipeline.
       */
      public void setBuffer(InputBuffer buffer) {
      }
  
  
      /**
       * Make the filter ready to process the next request.
       */
      public void recycle() {
      }
  
  
      /**
       * Return the name of the associated encoding; Here, the value is 
       * "void".
       */
      public ByteChunk getEncodingName() {
          return ENCODING;
      }
  
  
      /**
       * End the current request. It is acceptable to write extra bytes using
       * buffer.doWrite during the execution of this method.
       * 
       * @return Should return 0 unless the filter does some content length 
       * delimitation, in which case the number is the amount of extra bytes or
       * missing bytes, which would indicate an error. 
       * Note: It is recommended that extra bytes be swallowed by the filter.
       */
      public long end()
          throws IOException {
          return 0;
      }
  
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to