Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 77477 invoked from network); 5 Apr 2002 22:18:02 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 5 Apr 2002 22:18:02 -0000 Received: (qmail 8803 invoked by uid 97); 5 Apr 2002 22:17:58 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 8770 invoked by uid 97); 5 Apr 2002 22:17:57 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 8759 invoked by uid 97); 5 Apr 2002 22:17:57 -0000 Date: 5 Apr 2002 22:17:49 -0000 Message-ID: <20020405221749.17891.qmail@icarus.apache.org> From: costin@apache.org To: jakarta-tomcat-connectors-cvs@apache.org Subject: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3 CoyoteInterceptor2.java Tomcat3Request.java Tomcat3Response.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N costin 02/04/05 14:17:49 Modified: coyote/src/java/org/apache/coyote/tomcat3 CoyoteInterceptor2.java Tomcat3Request.java Tomcat3Response.java Log: One more step. The only remaining problem is implementing callbacks to the protocol that 'pull' information. Revision Changes Path 1.2 +2 -2 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteInterceptor2.java Index: CoyoteInterceptor2.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteInterceptor2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CoyoteInterceptor2.java 5 Apr 2002 18:42:03 -0000 1.1 +++ CoyoteInterceptor2.java 5 Apr 2002 22:17:49 -0000 1.2 @@ -193,9 +193,9 @@ */ public int preService(org.apache.tomcat.core.Request request, org.apache.tomcat.core.Response response) { - if(response instanceof CoyoteResponse) { + if(response instanceof Tomcat3Response) { try { - ((CoyoteResponse)response).sendAcknowledgement(); + ((Tomcat3Response)response).sendAcknowledgement(); } catch(Exception ex) { log("Can't send ACK", ex); } 1.2 +35 -48 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Request.java Index: Tomcat3Request.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Request.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Tomcat3Request.java 5 Apr 2002 18:42:03 -0000 1.1 +++ Tomcat3Request.java 5 Apr 2002 22:17:49 -0000 1.2 @@ -78,18 +78,23 @@ /** The Request to connect with Coyote. * This class handles the I/O requirements and transferring the request * line and Mime headers between Coyote and Tomcat. - * @Author Bill Barker + * + * @author Bill Barker + * @author Costin Manolache */ public class Tomcat3Request extends org.apache.tomcat.core.Request { org.apache.coyote.Request coyoteRequest=null; - - SSLSupport sslSupport=null; + + // For SSL attributes we need to call an ActionHook to get + // info from the protocol handler. + // SSLSupport sslSupport=null; + ByteChunk readChunk = new ByteChunk(); int pos=-1; int end=-1; byte [] readBuffer = null; - Socket socket = null; + public Tomcat3Request() { super(); @@ -100,11 +105,11 @@ public void recycle() { super.recycle(); if( coyoteRequest != null) coyoteRequest.recycle(); + remoteAddrMB.recycle(); remoteHostMB.recycle(); - readChunk.recycle(); - sslSupport=null; + readBuffer=null; pos=-1; end=-1; @@ -115,32 +120,22 @@ * attributes to the Tomcat attributes. */ 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.recycle(); - methodMB.recycle(); - uriMB.recycle(); - queryMB.recycle(); - protoMB.recycle(); - try { - schemeMB.duplicate(coyoteRequest.scheme()); - methodMB.duplicate(coyoteRequest.method()); - uriMB.duplicate(coyoteRequest.requestURI()); - queryMB.duplicate(coyoteRequest.query()); - protoMB.duplicate(coyoteRequest.protocol()); - } catch(IOException iex) { // ignore - } + coyoteRequest=cReq; + + // The CoyoteRequest/Tomcat3Request are bound togheter, they + // don't change. That means we can use the same field ( which + // doesn't change as well. + schemeMB = coyoteRequest.scheme(); + methodMB = coyoteRequest.method(); + uriMB = coyoteRequest.requestURI(); + queryMB = coyoteRequest.query(); + protoMB = coyoteRequest.protocol(); + headers = coyoteRequest.getMimeHeaders(); scookies.setHeaders(headers); params.setHeaders(headers); } - /** Set the socket for this request. - */ - public void setSocket(Socket socket) { - this.socket = socket; - } - + /** Read a single character from the request body. */ public int doRead() throws IOException { @@ -201,43 +196,35 @@ // -------------------- override special methods public MessageBytes remoteAddr() { - if( remoteAddrMB.isNull() ) { - remoteAddrMB.setString(socket.getInetAddress().getHostAddress()); - } + +// XXX Call back the protocol layer - lazy evaluation. +// if( remoteAddrMB.isNull() ) { +// remoteAddrMB.setString(socket.getInetAddress().getHostAddress()); +// } return remoteAddrMB; } public MessageBytes remoteHost() { - if( remoteHostMB.isNull() ) { - remoteHostMB.setString( socket.getInetAddress().getHostName() ); - } +// if( remoteHostMB.isNull() ) { +// remoteHostMB.setString( socket.getInetAddress().getHostName() ); +// } return remoteHostMB; } public String getLocalHost() { - InetAddress localAddress = socket.getLocalAddress(); - localHost = localAddress.getHostName(); +// InetAddress localAddress = socket.getLocalAddress(); +// localHost = localAddress.getHostName(); return localHost; } public MessageBytes serverName(){ - // if(! serverNameMB.isNull()) return serverNameMB; - // parseHostHeader(); + // That's set by protocol in advance, it's needed for mapping anyway, + // no need to do lazy eval. return coyoteRequest.serverName(); } public int getServerPort(){ - // if(serverPort!=-1) return serverPort; - //No need to delay execution - the host is certainly needed for - // mapping. - // parseHostHeader(); return coyoteRequest.getServerPort(); } - /** Define the SSL Support support instance for this socket. - */ - void setSSLSupport(SSLSupport s){ - sslSupport=s; - } - } 1.2 +9 -1 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Response.java Index: Tomcat3Response.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Response.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Tomcat3Response.java 5 Apr 2002 18:42:03 -0000 1.1 +++ Tomcat3Response.java 5 Apr 2002 22:17:49 -0000 1.2 @@ -81,8 +81,11 @@ class Tomcat3Response extends Response { String reportedname=null; + org.apache.coyote.Response coyoteResponse=null; + ByteChunk outputChunk = new ByteChunk(); + boolean acknowledged=false; public Tomcat3Response() { @@ -107,6 +110,7 @@ acknowledged=false; } + // XXX What is this ? */ public void setReported(String reported) { reportedname = reported; } @@ -114,6 +118,7 @@ public void endHeaders() throws IOException { super.endHeaders(); coyoteResponse.setStatus(getStatus()); + // Calls a sendHeaders callback to the protocol coyoteResponse.sendHeaders(); } @@ -121,6 +126,7 @@ throws IOException { if( count > 0 ) { + // XXX should be an explicit callback as well. outputChunk.setBytes(buffer, pos, count); coyoteResponse.doWrite( outputChunk ); } @@ -131,10 +137,12 @@ if( ! included ) coyoteResponse.reset(); } + public void finish() throws IOException { super.finish(); coyoteResponse.finish(); } + /** * Send an acknowledgment of a request. * @@ -145,7 +153,7 @@ if( status >= 300 ) // Don't ACK on errors. acknowledged = true; - // Don't ACK twice on the same request. (e.g. on a forward) + // Don't ACK twice on the same request. (e.g. on a forward) if(acknowledged) return; // Ignore any call from an included servlet -- To unsubscribe, e-mail: For additional commands, e-mail: