tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector RequestBase.java RequestStream.java ResponseBase.java ResponseStream.java ConnectorBase.java
Date Sun, 20 Feb 2000 02:55:07 GMT
craigmcc    00/02/19 18:55:06

  Modified:    proposals/catalina/src/share/org/apache/tomcat
                        Connector.java Request.java Response.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        ConnectorBase.java
  Added:       proposals/catalina/src/share/org/apache/tomcat/connector
                        RequestBase.java RequestStream.java
                        ResponseBase.java ResponseStream.java
  Log:
  Construct generic base classes for Connector, Request, and Response
  that will be generally useful in Connector implementations for Catalina,
  as well as related implementations of ServletInputStream and
  ServletOutputStream to be returned by the corresponding factory
  methods.
  
  There are many FIXMEs that need to be cleaned up before these classes
  are functional, but that's a job for another day.
  
  Revision  Changes    Path
  1.2       +26 -3     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Connector.java
  
  Index: Connector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Connector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Connector.java	2000/02/19 20:35:01	1.1
  +++ Connector.java	2000/02/20 02:55:05	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Connector.java,v 1.1 2000/02/19 20:35:01 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/02/19 20:35:01 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Connector.java,v 1.2 2000/02/20 02:55:05 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/02/20 02:55:05 $
    *
    * ====================================================================
    *
  @@ -94,7 +94,7 @@
    * normative.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/02/19 20:35:01 $
  + * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:05 $
    */
   
   public interface Connector {
  @@ -117,6 +117,29 @@
        * @param container The new Container to use
        */
       public void setContainer(Container container);
  +
  +
  +    /**
  +     * Return descriptive information about this Connector implementation.
  +     */
  +    public String getInfo();
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Create (or allocate) and return a Request object suitable for
  +     * specifying the contents of a Request to the responsible Container.
  +     */
  +    public Request createRequest();
  +
  +
  +    /**
  +     * Create (or allocate) and return a Response object suitable for
  +     * receiving the contents of a Response from the responsible Container.
  +     */
  +    public Response createResponse();
   
   
   }
  
  
  
  1.2       +50 -21    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Request.java	2000/01/20 06:33:38	1.1
  +++ Request.java	2000/02/20 02:55:05	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v 1.1 2000/01/20 06:33:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/01/20 06:33:38 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v 1.2 2000/02/20 02:55:05 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/02/20 02:55:05 $
    *
    * ====================================================================
    *
  @@ -70,6 +70,7 @@
   import java.security.Principal;
   import java.util.Locale;
   import javax.servlet.ServletException;
  +import javax.servlet.ServletInputStream;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletRequest;
   
  @@ -80,7 +81,7 @@
    * produce a corresponding Response.  
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/01/20 06:33:38 $
  + * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:05 $
    */
   
   public interface Request {
  @@ -90,6 +91,20 @@
   
   
       /**
  +     * Return the Connector through which this Request was received.
  +     */
  +    public Connector getConnector();
  +
  +
  +    /**
  +     * Set the Connector through which this Request was received.
  +     *
  +     * @param connector The new connector
  +     */
  +    public void setConnector(Connector connector);
  +
  +
  +    /**
        * Return the Context within which this Request is being processed.
        */
       public Context getContext();
  @@ -135,6 +150,20 @@
       public void setResponse(Response response);
   
   
  +    /**
  +     * Return the input stream associated with this Request.
  +     */
  +    public InputStream getStream();
  +
  +
  +    /**
  +     * Set the input stream associated with this Request.
  +     *
  +     * @param stream The new input stream
  +     */
  +    public void setStream(InputStream stream);
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -165,6 +194,15 @@
   
   
       /**
  +     * Create and return a ServletInputStream to read the content
  +     * associated with this Request.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public ServletInputStream createInputStream() throws IOException;
  +
  +
  +    /**
        * Release all object references, and initialize instance variables, in
        * preparation for reuse of this object.
        */
  @@ -200,15 +238,6 @@
   
   
       /**
  -     * Set the input stream associated with this Request.  This stream
  -     * will be wrapped by a Reader if <code>getReader()</code> is called.
  -     *
  -     * @param stream The new input stream
  -     */
  -    public void setInputStream(InputStream stream);
  -
  -
  -    /**
        * Set the HTTP request method used for this Request.
        *
        * @param method The request method
  @@ -254,6 +283,15 @@
   
   
       /**
  +     * Set the value to be returned by <code>isSecure()</code>
  +     * for this Request.
  +     *
  +     * @param secure The new isSecure value
  +     */
  +    public void setSecure(boolean secure);
  +
  +
  +    /**
        * Set the name of the server (virtual host) to process this request.
        *
        * @param name The server name
  @@ -267,15 +305,6 @@
        * @param port The server port
        */
       public void setServerPort(int port);
  -
  -
  -    /**
  -     * Set the value to be returned by <code>isSecure()</code>
  -     * for this Request.
  -     *
  -     * @param secure The new isSecure value
  -     */
  -    public void setSecure(boolean secure);
   
   
       /**
  
  
  
  1.2       +41 -12    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Response.java	2000/01/20 06:33:38	1.1
  +++ Response.java	2000/02/20 02:55:05	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v 1.1 2000/01/20 06:33:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/01/20 06:33:38 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v 1.2 2000/02/20 02:55:05 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/02/20 02:55:05 $
    *
    * ====================================================================
    *
  @@ -69,6 +69,7 @@
   import java.io.OutputStream;
   import java.util.Enumeration;
   import javax.servlet.ServletException;
  +import javax.servlet.ServletOutputStream;
   import javax.servlet.http.HttpServletResponse;
   
   
  @@ -78,7 +79,7 @@
    * processing of a corresponding Request.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/01/20 06:33:38 $
  + * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:05 $
    */
   
   public interface Response {
  @@ -88,6 +89,20 @@
   
   
       /**
  +     * Return the Connector through which this Response is returned.
  +     */
  +    public Connector getConnector();
  +
  +
  +    /**
  +     * Set the Connector through which this Response is returned.
  +     *
  +     * @param connector The new connector
  +     */
  +    public void setConnector(Connector connector);
  +
  +
  +    /**
        * Return the Context with which this Response is associated.
        */
       public Context getContext();
  @@ -131,10 +146,33 @@
       public HttpServletResponse getResponse();
   
   
  +    /**
  +     * Return the output stream associated with this Response.
  +     */
  +    public OutputStream getStream();
  +
  +
  +    /**
  +     * Set the output stream associated with this Response.
  +     *
  +     * @param stream The new output stream
  +     */
  +    public void setStream(OutputStream stream);
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
       /**
  +     * Create and return a ServletOutputStream to write the content
  +     * associated with this Response.
  +     *
  +     * @exception IOException if an input/output error occurs
  +     */
  +    public ServletOutputStream createOutputStream() throws IOException;
  +
  +
  +    /**
        * Ensure that the HTTP headers (and any buffered output) have been
        * flushed to the output stream, even if it was never acquired by
        * a servlet.
  @@ -196,15 +234,6 @@
        * preparation for reuse of this object.
        */
       public void recycle();
  -
  -
  -    /**
  -     * Set the output stream associated with this Response.  This stream will
  -     * be wrapped by a PrintWriter if <code>getWriter()</code> is called.
  -     *
  -     * @param stream The new output stream
  -     */
  -    public void setOutputStream(OutputStream stream);
   
   
   }
  
  
  
  1.2       +89 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ConnectorBase.java
  
  Index: ConnectorBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ConnectorBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectorBase.java	2000/02/19 20:35:01	1.1
  +++ ConnectorBase.java	2000/02/20 02:55:06	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ConnectorBase.java,v 1.1 2000/02/19 20:35:01 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/02/19 20:35:01 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ConnectorBase.java,v 1.2 2000/02/20 02:55:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/02/20 02:55:06 $
    *
    * ====================================================================
    *
  @@ -62,21 +62,24 @@
    */ 
   
   
  -package org.apache.tomcat;
  +package org.apache.tomcat.connector;
   
   
  +import java.util.Stack;
   import org.apache.tomcat.Connector;
   import org.apache.tomcat.Container;
  +import org.apache.tomcat.Request;
  +import org.apache.tomcat.Response;
   
   
   /**
    * Convenience base class implementation of the <b>Connector</b> interface.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/02/19 20:35:01 $
  + * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:06 $
    */
   
  -public class ConnectorBase implements Connector {
  +public abstract class ConnectorBase implements Connector {
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -85,9 +88,28 @@
       /**
        * The Container used for processing requests received by this Connector.
        */
  -    private Container container = null;
  +    protected Container container = null;
   
   
  +    /**
  +     * Descriptive information about this Connector implementation.
  +     */
  +    protected static final String info =
  +	"org.apache.tomcat.connector.ConnectorBase/1.0";
  +
  +
  +    /**
  +     * Collection of Requests available for allocation.
  +     */
  +    protected Stack requests = new Stack();
  +
  +
  +    /**
  +     * Collection of Responses available for allocation.
  +     */
  +    protected Stack responses = new Stack();
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -113,6 +135,67 @@
   	this.container = container;
   
       }
  +
  +
  +    /**
  +     * Return descriptive information about this Connector implementation.
  +     */
  +    public String getInfo() {
  +
  +	return (info);
  +
  +    }
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Create (or allocate) and return a Request object suitable for
  +     * specifying the contents of a Request to the responsible Container.
  +     */
  +    public Request createRequest() {
  +
  +	synchronized (requests) {
  +	    if (requests.size() > 0)
  +		return ((Request) requests.pop());
  +	    else
  +		return (newRequest());
  +	}
  +
  +    }
  +
  +
  +    /**
  +     * Create (or allocate) and return a Response object suitable for
  +     * receiving the contents of a Response from the responsible Container.
  +     */
  +    public Response createResponse() {
  +
  +	synchronized (responses) {
  +	    if (responses.size() > 0)
  +		return ((Response) responses.pop());
  +	    else
  +		return (newResponse());
  +	}
  +
  +    }
  +
  +
  +    /**
  +     * Instantiate and return a new Request object suitable for specifying
  +     * the contents of a Request to the responsible Container.  This method
  +     * must be implemented by a subclass.
  +     */
  +    public abstract Request newRequest();
  +
  +
  +    /**
  +     * Instantiate and return a new Response object suitable for receiving
  +     * the contents of a Response from the responsible Container.  This method
  +     * must be implemented by a subclass.
  +     */
  +    public abstract Response newResponse();
   
   
   }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java
  
  Index: RequestBase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v 1.1 2000/02/20 02:55:06 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/02/20 02:55:06 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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.tomcat.connector;
  
  
  import java.io.BufferedReader;
  import java.io.InputStream;
  import java.io.IOException;
  import java.security.Principal;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.ServletInputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import org.apache.tomcat.Connector;
  import org.apache.tomcat.Context;
  import org.apache.tomcat.Request;
  import org.apache.tomcat.Response;
  
  
  /**
   * Convenience base implementation of the <b>Request</b> interface, which can
   * be used for the Request implementation required by most Connectors.  Only
   * the connector-specific methods need to be implemented.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
   */
  
  public class RequestBase
      implements HttpServletRequest, Request {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The attributes associated with this Request, keyed by attribute name.
       */
      protected Hashtable attributes = new Hashtable();
  
  
      /**
       * The authentication type used for this request.
       */
      protected String authType = null;
  
  
      /**
       * The Connector through which this Request was received.
       */
      protected Connector connector = null;
  
  
      /**
       * The content length associated with this request.
       */
      protected int contentLength = -1;
  
  
      /**
       * The content type associated with this request.
       */
      protected String contentType = null;
  
  
      /**
       * The Context within which this Request is being processed.
       */
      protected Context context = null;
  
  
      /**
       * The set of cookies associated with this Request.
       */
      protected Vector cookies = new Vector();
  
  
      /**
       * The HTTP headers associated with this Request, keyed by name.
       */
      protected Hashtable headers = new Hashtable();
  
  
      /**
       * Descriptive information about this Request implementation.
       */
      protected static final String info =
  	"org.apache.tomcat.connector.RequestBase/1.0";
  
  
      /**
       * The preferred Locales assocaited with this Request.
       */
      protected Vector locales = new Vector();
  
  
      /**
       * The request method associated with this Request.
       */
      protected String method = null;
  
  
      /**
       * The protocol name and version associated with this Request.
       */
      protected String protocol = null;
  
  
      /**
       * The remote address associated with this request.
       */
      protected String remoteAddr = null;
  
  
      /**
       * The request URI associated with this request.
       */
      protected String requestUri = null;
  
  
      /**
       * The response with which this request is associated.
       */
      protected Response response = null;
  
  
      /**
       * The scheme associated with this Request.
       */
      protected String scheme = null;
  
  
      /**
       * Was this request received on a secure connection?
       */
      protected boolean secure = false;
  
  
      /**
       * The server name associated with this Request.
       */
      protected String serverName = null;
  
  
      /**
       * The server port associated with this Request.
       */
      protected int serverPort = -1;
  
  
      /**
       * The input stream associated with this Request.
       */
      protected InputStream stream = null;
  
  
      /**
       * The Principal who has been authenticated for this Request.
       */
      protected Principal userPrincipal;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the Connector through which this Request was received.
       */
      public Connector getConnector() {
  
  	return (this.connector);
  
      }
  
  
      /**
       * Set the Connector through which this Request was received.
       *
       * @param connector The new connector
       */
      public void setConnector(Connector connector) {
  
  	this.connector = connector;
  
      }
  
  
      /**
       * Return the Context within which this Request is being processed.
       */
      public Context getContext() {
  
  	return (this.context);
  
      }
  
  
      /**
       * Set the Context within which this Request is being processed.  This
       * must be called as soon as the appropriate Context is identified, because
       * it identifies the value to be returned by <code>getContextPath()</code>,
       * and thus enables parsing of the request URI.
       *
       * @param context The newly associated Context
       */
      public void setContext(Context context) {
  
  	this.context = context;
  
      }
  
  
      /**
       * Return descriptive information about this Request implementation and
       * the corresponding version number, in the format
       * <code>&lt;description&gt;/&lt;version&gt;</code>.
       */
      public String getInfo() {
  
  	return (info);
  
      }
  
  
      /**
       * Return the <code>HttpServletRequest</code> for which this object
       * is the facade.  This method must be implemented by a subclass.
       */
      public HttpServletRequest getRequest() {
  
  	return ((HttpServletRequest) this);
  
      }
  
  
      /**
       * Return the Response with which this Request is associated.
       */
      public Response getResponse() {
  
  	return (this.response);
  
      }
  
  
      /**
       * Set the Response with which this Request is associated.
       *
       * @param response The new associated response
       */
      public void setResponse(Response response) {
  
  	this.response = response;
  
      }
  
  
      /**
       * Return the input stream associated with this Request.
       */
      public InputStream getStream() {
  
  	return (this.stream);
  
      }
  
  
      /**
       * Set the input stream associated with this Request.
       *
       * @param stream The new input stream
       */
      public void setStream(InputStream stream) {
  
  	this.stream = stream;
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a Cookie to the set of Cookies associated with this Request.
       *
       * @param cookie The new cookie
       */
      public void addCookie(Cookie cookie) {
  
  	cookies.addElement(cookie);
  
      }
  
  
      /**
       * Add a Header to the set of Headers associated with this Request.
       *
       * @param name The new header name
       * @param value The new header value
       */
      public void addHeader(String name, String value) {
  
  	headers.put(name.toLowerCase(), value);
  
      }
  
  
      /**
       * Add a Locale to the set of preferred Locales for this Request.  The
       * first added Locale will be the first one returned by getLocales().
       *
       * @param locale The new preferred Locale
       */
      public void addLocale(Locale locale) {
  
  	locales.addElement(locale);
  
      }
  
  
      /**
       * Create and return a ServletInputStream to read the content
       * associated with this Request.
       *
       * @exception IOException if an input/output error occurs
       */
      public ServletInputStream createInputStream() throws IOException {
  
  	return (new RequestStream(this));
  
      }
  
  
      /**
       * Release all object references, and initialize instance variables, in
       * preparation for reuse of this object.
       */
      public void recycle() {
  
  	attributes.clear();
  	authType = null;
  	// connector is NOT reset when recycling
  	contentLength = -1;
  	contentType = null;
  	context = null;
  	cookies.removeAllElements();
  	headers.clear();
  	locales.removeAllElements();
  	method = null;
  	protocol = null;
  	response = null;
  	scheme = null;
  	serverName = null;
  	serverPort = -1;
  	stream = null;
  
      }
  
  
      /**
       * Set the authentication type used for this request, if any; otherwise
       * set the type to <code>null</code>.  Typical values are "BASIC",
       * "DIGEST", or "SSL".
       *
       * @param type The authentication type used
       */
      public void setAuthType(String type) {
  
  	this.authType = authType;
  
      }
  
  
      /**
       * Set the content length associated with this Request.
       *
       * @param length The new content length
       */
      public void setContentLength(int length) {
  
  	this.contentLength = length;
  
      }
  
  
      /**
       * Set the content type (and optionally the character encoding)
       * associated with this Request.  For example,
       * <code>text/html; charset=ISO-8859-4</code>.
       *
       * @param type The new content type
       */
      public void setContentType(String type) {
  
  	this.contentType = type;
  
      }
  
  
      /**
       * Set the HTTP request method used for this Request.
       *
       * @param method The request method
       */
      public void setMethod(String method) {
  
  	this.method = method;
  
      }
  
  
      /**
       * Set the protocol name and version associated with this Request.
       *
       * @param protocol Protocol name and version
       */
      public void setProtocol(String protocol) {
  
  	this.protocol = protocol;
  
      }
  
  
      /**
       * Set the remote IP address associated with this Request.  NOTE:  This
       * value will be used to resolve the value for <code>getRemoteHost()</code>
       * if that method is called.
       *
       * @param remote The remote IP address
       */
      public void setRemoteAddr(String remote) {
  
  	this.remoteAddr = remote;
  
      }
  
  
      /**
       * Set the unparsed request URI for this Request.  This value cannot be
       * parsed until <code>setContext()</code> has been called.  <b>FIXME</b>:
       * how and when is parsing initiated?
       *
       * @param uri The request URI
       */
      public void setRequestURI(String uri) {
  
  	this.requestUri = uri;
  
      }
  
  
      /**
       * Set the name of the scheme associated with this request.  Typical values
       * are <code>http</code>, <code>https</code>, and <code>ftp</code>.
       *
       * @param scheme The scheme
       */
      public void setScheme(String scheme) {
  
  	this.scheme = scheme;
  
      }
  
  
      /**
       * Set the value to be returned by <code>isSecure()</code>
       * for this Request.
       *
       * @param secure The new isSecure value
       */
      public void setSecure(boolean secure) {
  
  	this.secure = secure;
  
      }
  
  
      /**
       * Set the name of the server (virtual host) to process this request.
       *
       * @param name The server name
       */
      public void setServerName(String name) {
  
  	this.serverName = name;
  
      }
  
  
      /**
       * Set the port number of the server to process this request.
       *
       * @param port The server port
       */
      public void setServerPort(int port) {
  
  	this.serverPort = port;
  
      }
  
  
      /**
       * Set the Principal who has been authenticated for this Request.  This
       * value is also used to calculate the value to be returned by the
       * <code>getRemoteUser()</code> method.
       *
       * @param principal The user Principal
       */
      public void setUserPrincipal(Principal principal) {
  
  	this.userPrincipal = principal;
  
      }
  
  
      // ------------------------------------------------- ServletRequest Methods
  
  
      /**
       * Return the specified request attribute if it exists; otherwise, return
       * <code>null</code>.
       *
       * @param name Name of the request attribute to return
       */
      public Object getAttribute(String name) {
  
  	return ((String) attributes.get(name));
  
      }
  
  
      /**
       * Return the names of all request attributes for this Request, or an
       * empty <code>Enumeration</code> if there are none.
       */
      public Enumeration getAttributeNames() {
  
  	return (attributes.keys());
  
      }
  
  
      /**
       * Return the character encoding for this Request.
       */
      public String getCharacterEncoding() {
  
  	return (null);	// FIXME: getCharacterEncoding()
  
      }
  
  
      /**
       * Return the content length for this Request.
       */
      public int getContentLength() {
  
  	return (this.contentLength);
  
      }
  
  
      /**
       * Return the content type for this Request.
       */
      public String getContentType() {
  
  	return (contentType);
  
      }
  
  
      /**
       * Return the servlet input stream for this Request.
       *
       * @exception IllegalStateException if <code>getReader()</code> has
       *  already been called for this request
       * @exception IOException if an input/output error occurs
       */
      public ServletInputStream getInputStream() throws IOException {
  
  	return (null);	// FIXME: getInputStream()
  
      }
  
  
      /**
       * Return the preferred Locale that the client will accept content in,
       * based on the value for the first <code>Accept-Language</code> header
       * that was encountered.  If the request did not specify a preferred
       * language, the server's default Locale is returned.
       */
      public Locale getLocale() {
  
  	if (locales.size() > 0)
  	    return ((Locale) locales.elementAt(0));
  	else
  	    return (Locale.getDefault());
  
      }
  
  
      /**
       * Return the set of preferred Locales that the client will accept
       * content in, based on the values for any <code>Accept-Language</code>
       * headers that were encountered.  If the request did not specify a
       * preferred language, the server's default Locale is returned.
       */
      public Enumeration getLocales() {
  
  	if (locales.size() > 0)
  	    return (locales.elements());
  	Vector results = new Vector();
  	results.addElement(Locale.getDefault());
  	return (results.elements());
  
      }
  
  
      /**
       * Return the value of the specified request parameter, if any; otherwise,
       * return <code>null</code>.  If there is more than one value defined,
       * return only the first one.
       *
       * @param name Name of the desired request parameter
       */
      public String getParameter(String name) {
  
  	return (null);	// FIXME: getParameter()
  
      }
  
  
      /**
       * Return the names of all defined request parameters for this request.
       */
      public Enumeration getParameterNames() {
  
  	return (null);	// FIXME: getParameterNames()
  
      }
  
  
      /**
       * Return the defined values for the specified request parameter, if any;
       * otherwise, return <code>null</code>.
       *
       * @param name Name of the desired request parameter
       */
      public String[] getParameterValues(String name) {
  
  	return (null);	// FIXME: getParameterValues()
  
      }
  
  
      /**
       * Return the protocol and version used to make this Request.
       */
      public String getProtocol() {
  
  	return (this.protocol);
  
      }
  
  
      /**
       * Read the Reader wrapping the input stream for this Request.
       *
       * @exception IllegalStateException if <code>getInputStream()</code>
       *  has already been called for this request
       * @exception IOException if an input/output error occurs
       */
      public BufferedReader getReader() {
  
  	return (null);	// FIXME: getReader()
  
      }
  
  
      /**
       * Return the real path of the specified virtual path.
       *
       * @param path Path to be translated
       *
       * @deprecated As of version 2.1 of the Java Servlet API, use
       *  <code>ServletContext.getRealPath()</code>.
       */
      public String getRealPath(String path) {
  
  	return (null);	// FIXME: getRealPath()
  
      }
  
  
      /**
       * Return the remote IP address making this Request.
       */
      public String getRemoteAddr() {
  
  	return (this.remoteAddr);
  
      }
  
  
      /**
       * Return the remote host name making this Request.
       */
      public String getRemoteHost() {
  
  	return (null);	// FIXME: getRemoteHost()
  
      }
  
  
      /**
       * Return a RequestDispatcher that wraps the resource at the specified
       * path, which may be interpreted as relative to the current request path.
       *
       * @param path Path of the resource to be wrapped
       */
      public RequestDispatcher getRequestDispatcher(String path) {
  
  	return (null);	// FIXME: getRequestDispatcher()
  
      }
  
  
      /**
       * Return the scheme used to make this Request.
       */
      public String getScheme() {
  
  	return (this.scheme);
  
      }
  
  
      /**
       * Return the server name responding to this Request.
       */
      public String getServerName() {
  
  	return (this.serverName);
  
      }
  
  
      /**
       * Return the server port responding to this Request.
       */
      public int getServerPort() {
  
  	return (this.serverPort);
  
      }
  
  
      /**
       * Was this request received on a secure connection?
       */
      public boolean isSecure() {
  
  	return (this.secure);
  
      }
  
  
      /**
       * Remove the specified request attribute if it exists.
       *
       * @param name Name of the request attribute to remove
       */
      public void removeAttribute(String name) {
  
  	attributes.remove(name);
  
      }
  
  
      /**
       * Set the specified request attribute to the specified value.
       *
       * @param name Name of the request attribute to set
       * @param value The associated value
       */
      public void setAttribute(String name, Object value) {
  
  	attributes.put(name, value);
  
      }
  
  
      // --------------------------------------------- HttpServletRequest Methods
  
  
      /**
       * Return the authentication type used for this Request.
       */
      public String getAuthType() {
  
  	return (this.authType);
  
      }
  
  
      /**
       * Return the portion of the request URI used to select the Context
       * of the Request.
       */
      public String getContextPath() {
  
  	return (null);	// FIXME: getContextPath()
  
      }
  
  
      /**
       * Return the set of Cookies received with this Request.
       */
      public Cookie[] getCookies() {
  
  	synchronized (cookies) {
  	    Cookie results[] = new Cookie[cookies.size()];
  	    for (int i = 0; i < results.length; i++)
  		results[i] = (Cookie) cookies.elementAt(i);
  	    return (results);
  	}
  
      }
  
  
      /**
       * Return the value of the specified date header, if any; otherwise
       * return -1.
       *
       * @param name Name of the requested date header
       *
       * @exception IllegalArgumentException if the specified header value
       *  cannot be converted to a date
       */
      public long getDateHeader(String name) {
  
  	return (-1);	// FIXME: getDateHeader()
  
      }
  
  
      /**
       * Return the first value of the specified header, if any; otherwise,
       * return <code>null</code>
       *
       * @param name Name of the requested header
       */
      public String getHeader(String name) {
  
  	Vector values = (Vector) headers.get(name.toLowerCase());
  	if (values == null)
  	    return (null);
  	else
  	    return ((String) values.elementAt(0));
  
      }
  
  
      /**
       * Return all of the values of the specified header, if any; otherwise,
       * return <code>null</code>.
       *
       * @param name Name of the requested header
       */
      public Enumeration getHeaders(String name) {
  
  	Vector values = (Vector) headers.get(name.toLowerCase());
  	if (values != null)
  	    return (values.elements());
  	else
  	    return (null);
  
      }
  
  
      /**
       * Return the names of all headers received with this request.
       */
      public Enumeration getHeaderNames() {
  
  	return (headers.keys());
  
      }
  
  
      /**
       * Return the value of the specified header as an integer, or -1 if there
       * is no such header for this request.
       *
       * @param name Name of the requested header
       *
       * @exception IllegalArgumentException if the specified header value
       *  cannot be converted to an integer
       */
      public int getIntHeader(String name) {
  
  	return (-1);	// FIXME: getIntHeader()
  
      }
  
  
      /**
       * Return the HTTP request method used in this Request.
       */
      public String getMethod() {
  
  	return (this.method);
  
      }
  
  
      /**
       * Return the path information associated with this Request.
       */
      public String getPathInfo() {
  
  	return (null);	// FIXME: getPathInfo()
  
      }
  
  
      /**
       * Return the extra path information for this request, translated
       * to a real path.
       */
      public String getPathTranslated() {
  
  	return (null);	// FIXME: getPathTranslated()
  
      }
  
  
      /**
       * Return the query string associated with this request.
       */
      public String getQueryString() {
  
  	return (null);	// FIXME: getQueryString()
  
      }
  
  
      /**
       * Return the name of the remote user that has been authenticated
       * for this Request.
       */
      public String getRemoteUser() {
  
  	if (userPrincipal != null)
  	    return (userPrincipal.getName());
  	else
  	    return (null);
  
      }
  
  
      /**
       * Return the session identifier included in this request, if any.
       */
      public String getRequestedSessionId() {
  
  	return (null);	// FIXME: getRequestedSessionId()
  
      }
  
  
      /**
       * Return the request URI for this request.
       */
      public String getRequestURI() {
  
  	return (this.requestUri);
  
      }
  
  
      /**
       * Return the portion of the request URI used to select the servlet
       * that will process this request.
       */
      public String getServletPath() {
  
  	return (null);	// FIXME: getServletPath()
  
      }
  
  
      /**
       * Return the session associated with this Request, creating one
       * if necessary.
       */
      public HttpSession getSession() {
  
  	return (null);	// FIXME: getSession()
  
      }
  
  
      /**
       * Return the session associated with this Request, creating one
       * if necessary and requested.
       *
       * @param create Create a new session if one does not exist
       */
      public HttpSession getSession(boolean create) {
  
  	return (null);	// FIXME: getSession(create)
  
      }
  
  
      /**
       * Return <code>true</code> if the session identifier included in this
       * request came from a cookie.
       */
      public boolean isRequestedSessionIdFromCookie() {
  
  	return (false);	// FIXME: isRequestedSessionIdFromCookie()
  
      }
  
  
      /**
       * Return <code>true</code> if the session identifier included in this
       * request came from the request URI.
       */
      public boolean isRequestedSessionIdFromURL() {
  
  	return (false);	// FIXME: isRequestedSessionIdFromURL()
  
      }
  
  
      /**
       * Return <code>true</code> if the session identifier included in this
       * request came from the request URI.
       *
       * @deprecated As of Version 2.1 of the Java Servlet API, use
       *  <code>isRequestedSessionIdFromURL()</code> instead.
       */
      public boolean isRequestedSessionIdFromUrl() {
  
  	return (isRequestedSessionIdFromURL());
  
      }
  
  
      /**
       * Return <code>true</code> if the session identifier included in this
       * request identifies a valid session.
       */
      public boolean isRequestedSessionIdValid() {
  
  	return (false);	// FIXME: isRequestedSessionIdValid()
  
      }
  
  
      /**
       * Return <code>true</code> if the authenticated user principal
       * possesses the specified role name.  FIXME - Respect translations
       * in the web application deployment descriptor!
       *
       * @param role Role name to be validated
       */
      public boolean isUserInRole(String role) {
  
  	return (false);	// FIXME: isUserInRole()
  
      }
  
  
      /**
       * Return the principal that has been authenticated for this Request.
       */
      public Principal getUserPrincipal() {
  
  	return (userPrincipal);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java
  
  Index: RequestStream.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java,v 1.1 2000/02/20 02:55:06 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/02/20 02:55:06 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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.tomcat.connector;
  
  
  import java.io.InputStream;
  import java.io.IOException;
  import javax.servlet.ServletInputStream;
  import org.apache.tomcat.Request;
  
  
  /**
   * Convenience implementation of <b>ServletInputStream</b> that works with
   * the standard RequestBase implementation of <b>Request</b>.
   *
   * <b>FIXME</b>:  Enforce reading up to content length if specified
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
   */
  
  final class RequestStream
      extends ServletInputStream {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a servlet input stream associated with the specified Request.
       *
       * @param request The associated request
       */
      public RequestStream(Request request) {
  
  	super();
  	this.request = request;
  	this.stream = request.getStream();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Request with which this input stream is associated.
       */
      private Request request = null;
  
  
      /**
       * The underlying input stream from which we should read data.
       */
      private InputStream stream = null;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Read and return a single byte from this input stream.
       *
       * @exception IOException if an input/output error occurs
       */
      public int read() throws IOException {
  
  	return (stream.read());
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java
  
  Index: ResponseBase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v 1.1 2000/02/20 02:55:06 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/02/20 02:55:06 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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.tomcat.connector;
  
  
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.ServletException;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.tomcat.Connector;
  import org.apache.tomcat.Context;
  import org.apache.tomcat.Request;
  import org.apache.tomcat.Response;
  
  
  /**
   * Convenience base implementation of the <b>Response</b> interface, which can
   * be used for the Response implementation required by most Connectors.  Only
   * the connector-specific methods need to be implemented.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
   */
  
  public class ResponseBase
      implements Response, HttpServletResponse {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Connector through which this Response is returned.
       */
      protected Connector connector = null;
  
  
      /**
       * The content length associated with this Response.
       */
      protected int contentLength = -1;
  
  
      /**
       * The content type associated with this Response.
       */
      protected String contentType = "text/plain";
  
  
      /**
       * The Context within which this Response is being produced.
       */
      protected Context context = null;
  
  
      /**
       * The HTTP headers explicitly added via addHeader(), but not including
       * those to be added with setContentLength(), setContentType(), and so on.
       * This collection is keyed by the header name, and the elements are
       * Vectors containing the associated values that have been set.
       */
      protected Hashtable headers = new Hashtable();
  
  
      /**
       * Descriptive information about this Response implementation.
       */
      protected static final String info =
  	"org.apache.tomcat.connector.ResponseBase/1.0";
  
  
      /**
       * The Request with which this Response is associated.
       */
      protected Request request = null;
  
  
      /**
       * The HTTP status code associated with this Response.
       */
      protected int status = HttpServletResponse.SC_OK;
  
  
      /**
       * The output stream associated with this Response.
       */
      protected OutputStream stream = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the Connector through which this Response will be transmitted.
       */
      public Connector getConnector() {
  
  	return (this.connector);
  
      }
  
  
      /**
       * Set the Connector through which this Response will be transmitted.
       *
       * @param connector The new connector
       */
      public void setConnector(Connector connector) {
  
  	this.connector = connector;
  
      }
  
  
      /**
       * Return the Context with which this Response is associated.
       */
      public Context getContext() {
  
  	return (this.context);
  
      }
  
  
      /**
       * Set the Context with which this Response is associated.  This should
       * be called as soon as the appropriate Context is identified.
       *
       * @param context The associated Context
       */
      public void setContext(Context context) {
  
  	this.context = context;
  
      }
  
  
      /**
       * Return descriptive information about this Response implementation and
       * the corresponding version number, in the format
       * <code>&lt;description&gt;/&lt;version&gt;</code>.
       */
      public String getInfo() {
  
  	return (this.info);
  
      }
  
  
      /**
       * Return the Request with which this Response is associated.
       */
      public Request getRequest() {
  
  	return (this.request);
  
      }
  
  
      /**
       * Set the Request with which this Response is associated.
       *
       * @param request The new associated request
       */
      public void setRequest(Request request) {
  
  	this.request = request;
  
      }
  
  
      /**
       * Return the <code>HttpServletResponse</code> for which this object
       * is the facade.
       */
      public HttpServletResponse getResponse() {
  
  	return ((HttpServletResponse) this);
  
      }
  
  
      /**
       * Return the output stream associated with this Response.
       */
      public OutputStream getStream() {
  
  	return (this.stream);
  
      }
  
  
      /**
       * Set the output stream associated with this Response.
       *
       * @param stream The new output stream
       */
      public void setStream(OutputStream stream) {
  
  	this.stream = stream;
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Create and return a ServletOutputStream to write the content
       * associated with this Response.
       *
       * @exception IOException if an input/output error occurs
       */
      public ServletOutputStream createOutputStream() throws IOException {
  
  	return (new ResponseStream(this));
  
      }
  
  
      /**
       * Ensure that the HTTP headers (and any buffered output) have been
       * flushed to the output stream, even if it was never acquired by
       * a servlet.
       *
       * @exception IOException if an input/output error occurs
       */
      public void flush() throws IOException {
  
  	// FIXME: flush()
  
      }
  
  
      /**
       * Return the content length that was set or calculated for this Response.
       */
      public int getContentLength() {
  
  	return (this.contentLength);
  
      }
  
  
      /**
       * Return the content type that was set or calculated for this response,
       * or <code>null</code> if no content type was set.
       */
      public String getContentType() {
  
  	return (this.contentType);
  
      }
  
  
      /**
       * Return the value for the specified header, or <code>null</code> if this
       * header has not been set.  If more than one value was added for this
       * name, only the first is returned; use getHeaderValues() to retrieve all
       * of them.
       *
       * @param name Header name to look up
       */
      public String getHeader(String name) {
  
  	Vector values = (Vector) headers.get(name);
  	if (values != null)
  	    return ((String) values.elementAt(0));
  	else
  	    return (null);
  
      }
  
  
      /**
       * Return an enumeration all the header names set for this response, or
       * an empty Enumeration if no headers have been set.
       */
      public Enumeration getHeaderNames() {
  
  	return (headers.keys());
  
      }
  
  
      /**
       * Return an enumeration of all the header values associated with the
       * specified header name, or an empty enumeration if there are no such
       * header values.
       *
       * @param name Header name to look up
       */
      public Enumeration getHeaderValues(String name) {
  
  	Vector values = (Vector) headers.get(name);
  	if (values != null)
  	    return (values.elements());
  	else
  	    return (null);
  
      }
  
  
      /**
       * Return the HTTP status code associated with this Response.
       */
      public int getStatus() {
  
  	return (this.status);
  
      }
  
  
      /**
       * Release all object references, and initialize instance variables, in
       * preparation for reuse of this object.
       */
      public void recycle() {
  
  	// connector is NOT reset when recycling
  	contentLength = -1;
  	contentType = "text/plain";
  	context = null;
  	headers.clear();
  	request = null;
  	status = -1;
  	stream = null;
  
      }
  
  
      // ------------------------------------------------ ServletResponse Methods
  
  
      /**
       * Flush the buffer and commit this response.
       *
       * @exception IOException if an input/output error occurs
       */
      public void flushBuffer() throws IOException {
  
  	;	// FIXME: flushBuffer()
  
      }
  
  
      /**
       * Return the actual buffer size used for this Response.
       */
      public int getBufferSize() {
  
  	return (-1);	// FIXME: getBufferSize()
  
      }
  
  
      /**
       * Return the character encoding used for this Response.
       */
      public String getCharacterEncoding() {
  
  	return (null);	// FIXME: getCharacterEncoding()
  
      }
  
  
      /**
       * Return the servlet output stream associated with this Response.
       *
       * @exception IllegalStateException if <code>getWriter</code> has
       *  already been called for this response
       * @exception IOException if an input/output error occurs
       */
      public ServletOutputStream getOutputStream() throws IOException {
  
  	return (null);	// FIXME: getOutputStream()
  
      }
  
  
      /**
       * Return the Locale assigned to this response.
       */
      public Locale getLocale() {
  
  	return (null);
  
      }
  
  
      /**
       * Return the writer associated with this Response.
       *
       * @exception IllegalStateException if <code>getOutputStream</code> has
       *  already been called for this response
       * @exception IOException if an input/output error occurs
       */
      public PrintWriter getWriter() throws IOException {
  
  	return (null);	// FIXME: getWriter()
  
      }
  
  
      /**
       * Has the output of this response already been committed?
       */
      public boolean isCommitted() {
  
  	return (false);	// FIXME: isCommitted()
  
      }
  
  
      /**
       * Clear any content written to the buffer.
       *
       * @exception IllegalStateException if this response has already
       *  been committed
       */
      public void reset() {
  
  	;	// FIXME: reset()
  
      }
  
  
      /**
       * Set the buffer size to be used for this Response.
       *
       * @param size The new buffer size
       *
       * @exception IllegalStateException if this method is called after
       *  output has been committed for this response
       */
      public void setBufferSize(int size) {
  
  	;	// FIXME: setBufferSize()
  
      }
  
  
      /**
       * Set the content length (in bytes) for this Response.
       *
       * @param length The new content length
       */
      public void setContentLength(int length) {
  
  	this.contentLength = length;
  
      }
  
  
      /**
       * Set the content type for this Response.
       *
       * @param type The new content type
       */
      public void setContentType(String type) {
  
  	this.contentType = type;
  
      }
  
  
      /**
       * Set the Locale that is appropriate for this response, including
       * setting the appropriate character encoding.
       *
       * @param locale The new locale
       */
      public void setLocale(Locale locale) {
  
  	;	// FIXME: setLocale()
  
      }
  
  
      // -------------------------------------------- HttpServletResponse Methods
  
  
      /**
       * Add the specified Cookie to those that will be included with
       * this Response.
       *
       * @param cookie Cookie to be added
       */
      public void addCookie(Cookie cookie) {
  
  	;	// FIXME: addCookie()
  
      }
  
  
      /**
       * Add the specified date header to the specified value.
       *
       * @param name Name of the header to set
       * @param value Date value to be set
       */
      public void addDateHeader(String name, long value) {
  
  	;	// FIXME: setDateHeader()
  
      }
  
  
      /**
       * Add the specified header to the specified value.
       *
       * @param name Name of the header to set
       * @param value Value to be set
       */
      public void addHeader(String name, String value) {
  
  	;	// FIXME: addHeader()
  
      }
  
  
      /**
       * Add the specified integer header to the specified value.
       *
       * @param name Name of the header to set
       * @param value Integer value to be set
       */
      public void addIntHeader(String name, int value) {
  
  	;	// FIXME: addIntHeader()
  
      }
  
  
      /**
       * Has the specified header been set already in this response?
       *
       * @param name Name of the header to check
       */
      public boolean containsHeader(String name) {
  
  	return (false);	// FIXME: containsHeader
  
      }
  
  
      /**
       * Encode the session identifier associated with this response
       * into the specified redirect URL, if necessary.
       *
       * @param url URL to be encoded
       */
      public String encodeRedirectURL(String url) {
  
  	return (url);	// FIXME: encodeRedirectURL()
  
      }
  
  
      /**
       * Encode the session identifier associated with this response
       * into the specified redirect URL, if necessary.
       *
       * @param url URL to be encoded
       *
       * @deprecated As of Version 2.1 of the Java Servlet API, use
       *  <code>encodeRedirectURL()</code> instead.
       */
      public String encodeRedirectUrl(String url) {
  
  	return (encodeRedirectURL(url));
  
      }
  
  
      /**
       * Encode the session identifier associated with this response
       * into the specified URL, if necessary.
       *
       * @param url URL to be encoded
       */
      public String encodeURL(String url) {
  
  	return (url);	// FIXME: encodeURL()
  
      }
  
  
      /**
       * Encode the session identifier associated with this response
       * into the specified URL, if necessary.
       *
       * @param url URL to be encoded
       *
       * @deprecated As of Version 2.1 of the Java Servlet API, use
       *  <code>encodeURL()</code> instead.
       */
      public String encodeUrl(String url) {
  
  	return (encodeURL(url));
  
      }
  
  
      /**
       * Send an error response with the specified status and a
       * default message.
       *
       * @param status HTTP status code to send
       *
       * @exception IllegalStateException if this response has
       *  already been committed
       * @exception IOException if an input/output error occurs
       */
      public void sendError(int status) throws IOException {
  
  	;	// FIXME: sendError(status)
  
      }
  
  
      /**
       * Send an error response with the specified status and message.
       *
       * @param status HTTP status code to send
       * @param message Corresponding message to send
       *
       * @exception IllegalStateException if this response has
       *  already been committed
       * @exception IOException if an input/output error occurs
       */
      public void sendError(int status, String message) throws IOException {
  
  	;	// FIXME: sendError(status, message)
  
      }
  
  
      /**
       * Send a temporary redirect to the specified redirect location URL.
       *
       * @param location Location URL to redirect to
       *
       * @exception IllegalStateException if this response has
       *  already been committed
       * @exception IOException if an input/output error occurs
       */
      public void sendRedirect(String location) throws IOException {
  
  	;	// FIXME: sendRedirect()
  
      }
  
  
      /**
       * Set the specified date header to the specified value.
       *
       * @param name Name of the header to set
       * @param date Date value to be set
       */
      public void setDateHeader(String name, long date) {
  
  	;	// FIXME: setDateHeader()
  
      }
  
  
      /**
       * Set the specified header to the specified value.
       *
       * @param name Name of the header to set
       * @param value Value to be set
       */
      public void setHeader(String name, String value) {
  
  	;	// FIXME: setHeader()
  
      }
  
  
      /**
       * Set the specified integer header to the specified value.
       *
       * @param name Name of the header to set
       * @param value Integer value to be set
       */
      public void setIntHeader(String name, int value) {
  
  	;	// FIXME: setIntHeader()
  
      }
  
  
      /**
       * Set the HTTP status to be returned with this response.
       *
       * @param status The new HTTP status
       */
      public void setStatus(int status) {
  
  	;	// FIXME: setStatus(status)
  
      }
  
  
      /**
       * Set the HTTP status and message to be returned with this response.
       *
       * @param status The new HTTP status
       * @param message The associated text message
       *
       * @deprecated As of Version 2.1 of the Java Servlet API, this method
       *  has been deprecated due to the ambiguous meaning of the message
       *  parameter.
       */
      public void setStatus(int status, String message) {
  
  	;	// FIXME: setStatus(status, message)
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java
  
  Index: ResponseStream.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseStream.java,v 1.1 2000/02/20 02:55:06 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/02/20 02:55:06 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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.tomcat.connector;
  
  
  import java.io.IOException;
  import java.io.OutputStream;
  import javax.servlet.ServletOutputStream;
  import org.apache.tomcat.Response;
  
  
  /**
   * Convenience implementation of <b>ServletOutputStream</b> that works with
   * the standard ResponseBase implementation of <b>Response</b>.
   *
   * <b>FIXME</b>:  Enforce writing up to content length if specified
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
   */
  
  final class ResponseStream
      extends ServletOutputStream {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a servlet output stream associated with the specified Request.
       *
       * @param response The associated response
       */
      public ResponseStream(Response response) {
  
  	super();
  	this.response = response;
  	this.stream = response.getStream();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Response with which this input stream is associated.
       */
      private Response response = null;
  
  
      /**
       * The underlying output stream to which we should write data.
       */
      private OutputStream stream = null;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Write the specified byte to our output stream.
       *
       * @param b The byte to be written
       *
       * @exception IOException if an input/output error occurs
       */
      public void write(int b) throws IOException {
  
  	stream.write(b);
  
      }
  
  
  }
  
  
  

Mime
View raw message