You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2002/03/10 07:14:38 UTC

cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3 CoyoteInterceptor.java CoyoteProcessor.java CoyoteRequest.java CoyoteResponse.java

billbarker    02/03/09 22:14:37

  Added:       coyote/src/java/org/apache/coyote/tomcat3
                        CoyoteInterceptor.java CoyoteProcessor.java
                        CoyoteRequest.java CoyoteResponse.java
  Log:
  Adding the Tomcat 3.3 Coyote file.
  
  They all compile, which is enough for an initial check-in.  The threading and socket handling is all standard 3.3.x stuff.
  
  TODO:
    - Improve the handling of the Response headers.
    - Review (and likely improve) the handling of the Request headers.
    - Create the WAR module to allow this to be plugged in.
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteInterceptor.java
  
  Index: CoyoteInterceptor.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 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.coyote.tomcat3;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.res.StringManager;
  import org.apache.tomcat.util.buf.*;
  import org.apache.tomcat.util.http.*;
  import org.apache.tomcat.util.net.*;
  import org.apache.tomcat.util.net.ServerSocketFactory;
  import org.apache.tomcat.util.log.*;
  import org.apache.tomcat.util.compat.*;
  import org.apache.tomcat.modules.server.PoolTcpConnector;
  import org.apache.coyote.Adapter;
  import org.apache.coyote.Processor;
  
  /** Standalone http.
   *
   *  Connector properties:
   *  <ul>
   *  <li> secure - will load a SSL socket factory and act as https server</li>
   *  </ul>
   *
   *  Properties passed to the net layer:
   *  <ul>
   *  <li>timeout</li>
   *  <li>backlog</li>
   *  <li>address</li>
   *  <li>port</li>
   *  </ul>
   * Thread pool properties:
   *  <ul>
   *  <li>minSpareThreads</li>
   *  <li>maxSpareThreads</li>
   *  <li>maxThreads</li>
   *  <li>poolOn</li>
   *  </ul>
   * Properties for HTTPS:
   *  <ul>
   *  <li>keystore - certificates - default to ~/.keystore</li>
   *  <li>keypass - password</li>
   *  <li>clientauth - true if the server should authenticate the client using certs</li>
   *  </ul>
   * Properties for HTTP:
   *  <ul>
   *  <li>reportedname - name of server sent back to browser (security purposes)</li>
   *  </ul>
   */
  public class CoyoteInterceptor extends PoolTcpConnector
      implements  TcpConnectionHandler
  {
      private int	timeout = 300000;	// 5 minutes as in Apache HTTPD server
      private String reportedname;
      private int socketCloseDelay=-1;
      private String processorClassName="org.apache.coyote.http11.Http11Processor";
  
      public CoyoteInterceptor() {
  	super();
          super.setSoLinger( 100 );
  	// defaults:
  	this.setPort( 8080 );
      }
  
      // -------------------- PoolTcpConnector --------------------
  
      protected void localInit() throws Exception {
  	ep.setConnectionHandler( this );
      }
  
      // -------------------- Attributes --------------------
      public void setTimeout( int timeouts ) {
  	timeout = timeouts * 1000;
      }
      public void setReportedname( String reportedName) {
  	reportedname = reportedName;
      }
  
      public void setSocketCloseDelay( int d ) {
          socketCloseDelay=d;
      }
  
      public void setProperty( String prop, String value ) {
          setAttribute( prop, value );
      }
  
      // -------------------- Handler implementation --------------------
      public void setServer( Object o ) {
  	this.cm=(ContextManager)o;
      }
      
      public Object[] init() {
  	Object thData[]=new Object[3];
  	CoyoteProcessor adaptor = new CoyoteProcessor(cm);
  	if( secure )
  	    adaptor.setSSLImplementation(sslImplementation);
  	Processor processor = null;
  	try {
  	    Class processorClass = 
  		getClass().getClassLoader().loadClass(processorClassName);
  	    processor = (Processor)processorClass.newInstance();
  	} catch(Exception ex) {
  	    log("Can't load Processor", ex);
  	}
  
  	thData[0]=adaptor;
  	thData[1]=processor;
  	thData[2]=null;
  	return  thData;
      }
  
      public void processConnection(TcpConnection connection, Object thData[]) {
  	Socket socket=null;
  	CoyoteProcessor adaptor=null;
  	Processor  processor=null;
  	try {
  	    adaptor=(CoyoteProcessor)thData[0];
  	    processor=(Processor)thData[1];
  	    processor.setAdapter(adaptor);
  	    socket=connection.getSocket();
   	    socket.setSoTimeout(timeout);
  
  	    InputStream in = socket.getInputStream();
  	    OutputStream out = socket.getOutputStream();
  	    adaptor.setSocket(socket);
  	    processor.process(in, out);
              // If unread input arrives after the shutdownInput() call
              // below and before or during the socket.close(), an error
              // may be reported to the client.  To help troubleshoot this
              // type of error, provide a configurable delay to give the
              // unread input time to arrive so it can be successfully read
              // and discarded by shutdownInput().
              if( socketCloseDelay >= 0 ) {
                  try {
                      Thread.sleep(socketCloseDelay);
                  } catch (InterruptedException ie) { /* ignore */ }
              }
  
  	    TcpConnection.shutdownInput( socket );
  	} catch(java.net.SocketException e) {
  	    // SocketExceptions are normal
  	    log( "SocketException reading request, ignored", null,
  		 Log.INFORMATION);
  	    log( "SocketException reading request:", e, Log.DEBUG);
  	} catch (java.io.IOException e) {
  	    // IOExceptions are normal 
  	    log( "IOException reading request, ignored", null,
  		 Log.INFORMATION);
  	    log( "IOException reading request:", e, Log.DEBUG);
  	}
  	// Future developers: if you discover any other
  	// rare-but-nonfatal exceptions, catch them here, and log as
  	// above.
  	catch (Throwable e) {
  	    // any other exception or error is odd. Here we log it
  	    // with "ERROR" level, so it will show up even on
  	    // less-than-verbose logs.
  	    e.printStackTrace();
  	    log( "Error reading request, ignored", e, Log.ERROR);
  	} finally {
  	    // recycle kernel sockets ASAP
  	    try { if (socket != null) socket.close (); }
  	    catch (IOException e) { /* ignore */ }
          }
      }
   
       /**
         getInfo calls for SSL data
   
         @return the requested data
       */
       public Object getInfo( Context ctx, Request request,
   			   int id, String key ) {
         // The following code explicitly assumes that the only
         // attributes hand;ed here are HTTP. If you change that
         // you MUST change the test for sslSupport==null --EKR
   
         CoyoteRequest httpReq;
  
         
         try {
   	httpReq=(CoyoteRequest)request;
         } catch (ClassCastException e){
   	return null;
         }
   
         if(key!=null && httpReq!=null && httpReq.sslSupport!=null){
   	  try {
   	      if(key.equals("javax.servlet.request.cipher_suite"))
   		  return httpReq.sslSupport.getCipherSuite();
   	      if(key.equals("javax.servlet.request.X509Certificate"))
   		  return httpReq.sslSupport.getPeerCertificateChain();
   	  } catch (Exception e){
   	      log("Exception getting SSL attribute " + key,e,Log.WARNING);
   	      return null;
   	  }
         }
         return super.getInfo(ctx,request,id,key);
       }
  }
  
  
  
  
  1.1                  jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteProcessor.java
  
  Index: CoyoteProcessor.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 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.coyote.tomcat3;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.res.StringManager;
  import org.apache.tomcat.util.buf.*;
  import org.apache.tomcat.util.http.*;
  import org.apache.tomcat.util.net.*;
  import org.apache.tomcat.util.net.ServerSocketFactory;
  import org.apache.tomcat.util.log.*;
  import org.apache.tomcat.util.compat.*;
  import org.apache.coyote.Adapter;
  import org.apache.coyote.Processor;
  
  class CoyoteProcessor implements Adapter {
      private CoyoteRequest reqA;
      private CoyoteResponse resA;
      private ContextManager cm;
      private boolean secure=false;
      private Socket socket=null;
      private SSLImplementation sslImplementation=null;
  
      CoyoteProcessor(ContextManager ctxman) {
  	cm   = ctxman;
  	reqA=new CoyoteRequest();
  	resA=new CoyoteResponse();
  	cm.initRequest( reqA, resA );
      }
  
      public void recycle() {
  	secure = false;
  	sslImplementation=null;
      }
  
      public void setSSLImplementation(SSLImplementation ssl) {
  	sslImplementation = ssl;
      }
      public void setSecure(boolean isSecure) {
  	secure = isSecure;
      }
      public void setSocket(Socket socket) {
  	if( secure ) {
  	    // Load up the SSLSupport class
  	    if(sslImplementation != null)
  		reqA.setSSLSupport(sslImplementation.getSSLSupport(socket));
  	}
      }
      public void service(org.apache.coyote.Request request, 
  			org.apache.coyote.Response response) 
  	    throws Exception{
  	reqA.setCoyoteRequest(request);
  	resA.setCoyoteResponse(response);
  	if( secure ) {
  	    reqA.scheme().setString( "https" );
  	    
   		// Load up the SSLSupport class
  	    if(sslImplementation != null)
  		reqA.setSSLSupport(sslImplementation.getSSLSupport(socket));
  	}
  	    
  	cm.service( reqA, resA );
  
      }
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteRequest.java
  
  Index: CoyoteRequest.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 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.coyote.tomcat3;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.res.StringManager;
  import org.apache.tomcat.util.buf.*;
  import org.apache.tomcat.util.http.*;
  import org.apache.tomcat.util.net.*;
  import org.apache.tomcat.util.net.ServerSocketFactory;
  import org.apache.tomcat.util.log.*;
  import org.apache.tomcat.util.compat.*;
  import org.apache.coyote.Adapter;
  import org.apache.coyote.Processor;
  
  class CoyoteRequest extends Request {
  
      org.apache.coyote.Request coyoteRequest=null;
      SSLSupport sslSupport=null;
      ByteChunk  readChunk = new ByteChunk();
      int  pos=-1;
      int  end=-1;
      byte [] readBuffer = null;
      
      public CoyoteRequest() {
          super();
      }
  
      public void recycle() {
  	super.recycle();
  	if( coyoteRequest != null) coyoteRequest.recycle();
  
  	readChunk.recycle();
  	sslSupport=null;
  	pos=-1;
  	end=-1;
      }
  
      public void setCoyoteRequest(org.apache.coyote.Request cReq) {
  	coyoteRequest=cReq;
  	// This is really ugly, but fast.
  	// I could still be talked out of it.
  	schemeMB = coyoteRequest.scheme();
  	methodMB = coyoteRequest.method();
  	uriMB    = coyoteRequest.requestURI();
  	queryMB  = coyoteRequest.query();
  	protoMB  = coyoteRequest.protocol();
  	headers  = coyoteRequest.getMimeHeaders();
  	params.setQuery(queryMB);
  	params.setHeaders(headers);
      }
  
  
      public int doRead() throws IOException {
  	if( available == 0 ) 
  	    return -1;
  	// #3745
  	// if available == -1: unknown length, we'll read until end of stream.
  	if( available!= -1 )
  	    available--;
  	if(pos >= end) {
  	    if(doRead() < 0)
  		return -1;
  	}
  	return readBuffer[pos++] & 0xFF;
      }
  
      public int doRead(byte[] b, int off, int len) throws IOException {
  	if( available == 0 )
  	    return -1;
  	// if available == -1: unknown length, we'll read until end of stream.
  	if(pos >= end) {
  	    if(doRead() < 0) 
  		return -1;
  	}
  	int rd = -1;
  	if((end - pos) > len) {
  	    rd = len;
  	} else {
  	    rd = end - pos;
  	}
  
          System.arraycopy(readBuffer, pos, b, off, rd);
  	pos += rd;
  	if( available!= -1 )
  	    available -= rd;
  
  	return rd;
      }
      
      /**
       * Read bytes to the read chunk buffer.
       */
      protected int readBytes()
          throws IOException {
  
          int result = coyoteRequest.doRead(readChunk);
          if (result > 0) {
              readBuffer = readChunk.getBytes();
              end = readChunk.getEnd();
              pos = readChunk.getStart();
          }
          return result;
  
      }
  
  
      // -------------------- override special methods
  
      public MessageBytes remoteAddr() {
  	return coyoteRequest.remoteAddr();
      }
  
      public MessageBytes remoteHost() {
  	return coyoteRequest.remoteHost();
      }
  
      public String getLocalHost() {
  	return coyoteRequest.getLocalHost();
      }
  
      public MessageBytes serverName(){
          return coyoteRequest.serverName();
      }
  
      public int getServerPort(){
          return coyoteRequest.getServerPort();
      }
  
      void setSSLSupport(SSLSupport s){
          sslSupport=s;
      }
   
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteResponse.java
  
  Index: CoyoteResponse.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 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.coyote.tomcat3;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.res.StringManager;
  import org.apache.tomcat.util.buf.*;
  import org.apache.tomcat.util.http.*;
  import org.apache.tomcat.util.net.*;
  import org.apache.tomcat.util.net.ServerSocketFactory;
  import org.apache.tomcat.util.log.*;
  import org.apache.tomcat.util.compat.*;
  
  
  
  
  class CoyoteResponse extends  Response {
      String reportedname=null;
      DateFormat dateFormat=null;
      org.apache.coyote.Response coyoteResponse=null;
      ByteChunk outputChunk = new ByteChunk();
      
      public CoyoteResponse() {
          super();
      }
  
      public void setCoyoteResponse(org.apache.coyote.Response cRes) {
  	coyoteResponse = cRes;
      }
  
      public void init() {
  	super.init();
  	dateFormat=new SimpleDateFormat(DateTool.RFC1123_PATTERN,
  					Locale.US);
  	dateFormat.setTimeZone(DateTool.GMT_ZONE);
      }
      
  
      public void recycle() {
  	super.recycle();
  	if(coyoteResponse != null) coyoteResponse.recycle();
  	outputChunk.recycle();
      }
  
      public void setReported(String reported) {
          reportedname = reported;
      }
  
      public void endHeaders()  throws IOException {
  	super.endHeaders();
  	Enumeration names = getMimeHeaders().names();
  	while( names.hasMoreElements() ) {
  	    String hname = (String)names.nextElement();
  	    Enumeration values = getMimeHeaders().values(hname);
  	    while( values.hasMoreElements() ) {
  		String hvalue = (String)values.nextElement();
  		coyoteResponse.addHeader(hname, hvalue);
  	    }
  	}
  	coyoteResponse.sendHeaders();
      }
  
      public void doWrite( byte buffer[], int pos, int count)
  	throws IOException
      {
  	if( count > 0 ) {
  	    outputChunk.setBytes(buffer, pos, count);
  	    coyoteResponse.doWrite( outputChunk );
  	}
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>