costin 02/01/25 23:25:53 Modified: jk/java/org/apache/jk/common HandlerRequest.java MsgAjp.java WorkerDummy.java Log: Updates ( similar with what changed on the C side ), fixes. Revision Changes Path 1.2 +11 -14 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java Index: HandlerRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HandlerRequest.java 31 Dec 2001 19:02:01 -0000 1.1 +++ HandlerRequest.java 26 Jan 2002 07:25:53 -0000 1.2 @@ -75,8 +75,10 @@ * Handle messages related with basic request information. * * This object can handle the following incoming messages: - * - "FORWARD_REQUEST" input message ( sent when a request is passed from the web server ) - * - "RECEIVE_BODY_CHUNK" input ( sent by container to pass more body, in response to GET_BODY_CHUNK ) + * - "FORWARD_REQUEST" input message ( sent when a request is passed from the + * web server ) + * - "RECEIVE_BODY_CHUNK" input ( sent by container to pass more body, in + * response to GET_BODY_CHUNK ) * * It can handle the following outgoing messages: * - SEND_HEADERS. Pass the status code and headers. @@ -198,7 +200,7 @@ { } - public void init( WorkerEnv we ) { + public void init() { // register incoming message handlers we.registerMessageType( JK_AJP13_FORWARD_REQUEST, "JK_AJP13_FORWARD_REQUEST", @@ -224,12 +226,6 @@ int postMsgNote=5; int tmpBufNote=6; - Worker w; - - public void setWorker( Worker w ) { - this.w=w; - } - public int callback(int type, Channel ch, Endpoint ep, Msg msg) throws IOException { @@ -244,7 +240,7 @@ decodeRequest( msg, req, ch, ep ); /* XXX it should be computed from request, by workerEnv */ - w.service( req, ch, ep ); + worker.service( req, ch, ep ); return OK; } @@ -256,6 +252,7 @@ // Translate the HTTP method code to a String. byte methodCode = msg.getByte(); String mName=methodTransArray[(int)methodCode - 1]; + req.method().setString(mName); msg.getBytes(req.protocol()); @@ -290,12 +287,12 @@ } /* Read present data */ - int err = postMsg.receive(ch, ep); + int err = ch.receive(postMsg, ep); } if (dL > 5) { d(req.toString()); - } + } return OK; } @@ -385,7 +382,7 @@ jsseCerts); break; - case SC_A_SSL_CIPHER : + case SC_A_SSL_CIPHER : req.setSecure( true ); msg.getBytes(tmpMB); req.setAttribute("javax.servlet.request.cipher_suite", @@ -453,7 +450,7 @@ } } - private static final int dL=10; + private static final int dL=0; private static void d(String s ) { System.err.println( "HandlerRequest: " + s ); } 1.4 +21 -63 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/MsgAjp.java Index: MsgAjp.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/MsgAjp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MsgAjp.java 12 Jan 2002 04:03:42 -0000 1.3 +++ MsgAjp.java 26 Jan 2002 07:25:53 -0000 1.4 @@ -90,16 +90,16 @@ */ public class MsgAjp extends Msg { - byte buf[]=new byte[8300]; + private byte buf[]=new byte[8300]; // The current read or write position in the buffer - int pos; + private int pos; /** * This actually means different things depending on whether the * packet is read or write. For read, it's the length of the * payload (excluding the header). For write, it's the length of * the packet as a whole (counting the header). Oh, well. */ - int len; + private int len; @@ -128,7 +128,15 @@ buf[2]= (byte)((dLen>>>8 ) & 0xFF ); buf[3] = (byte)(dLen & 0xFF); } - + + public byte[] getBuffer() { + return buf; + } + + public int getLen() { + return len; + } + // ============ Data Writing Methods =================== /** @@ -200,7 +208,8 @@ */ public void appendBytes( byte b[], int off, int numBytes ) { if( pos + numBytes >= buf.length ) { - System.out.println("Buffer overflow " + buf.length + " " + pos + " " + numBytes ); + System.out.println("Buffer overflow " + buf.length + " " + + pos + " " + numBytes ); return; } appendInt( numBytes ); @@ -210,7 +219,8 @@ private void cpBytes( byte b[], int off, int numBytes ) { if( pos + numBytes >= buf.length ) { - System.out.println("Buffer overflow " + buf.length + " " + pos + " " + numBytes ); + System.out.println("Buffer overflow " + buf.length + " " + + pos + " " + numBytes ); return; } System.arraycopy( b, off, buf, pos, numBytes); @@ -300,42 +310,11 @@ return b1; } - /** - * Send a packet to the web server. Works for any type of message. - * - * @param msg A packet with accumulated data to send to the server -- - * this method will write out the length in the header. - */ - public void send(Channel ch, Endpoint ep) throws IOException { - - this.end(); // Write the packet header - - if (dL > 5 ) - d("send() " + len + " " + buf[4] ); - - ch.write( ep, buf, 0, len ); + public int getHeaderLength() { + return 4; } - public int receive(Channel ch, Endpoint ep) throws IOException { - if (dL > 0) { - d("receive()"); - } - - // XXX If the length in the packet header doesn't agree with the - // actual number of bytes read, it should probably return an error - // value. Also, callers of this method never use the length - // returned -- should probably return true/false instead. - - int rd = ch.read(ep, buf, 0, 4 ); - - // XXX - connection closed (JK_AJP13_COMM_CLOSED) - // - connection broken (JK_AJP13_COMM_BROKEN) - // - if(rd < 0) { - // Most likely normal apache restart. - return rd; - } - + public int processHeader() { pos = 0; int mark = getInt(); len = getInt(); @@ -348,30 +327,9 @@ } if( dL > 5 ) - d( "Received " + rd + " " + len + " " + buf[0] ); - - // XXX check if enough space - it's assert()-ed !!! - - int total_read = 0; - - total_read = ch.read(ep, buf, 4, len); - - if (total_read <= 0) { - d("can't read body, waited #" + len); - return -1; - } - - if (total_read != len) { - d( "incomplete read, waited #" + len + - " got only " + total_read); - return -2; - } - - if (dL > 0) - d("receive: total read = " + total_read); - return total_read; + d( "Received " + len + " " + buf[0] ); + return len; } - public void dump(String msg) { System.out.println( msg + ": " + buf + " " + pos +"/" + (len + 4)); 1.3 +5 -14 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/WorkerDummy.java Index: WorkerDummy.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/WorkerDummy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WorkerDummy.java 21 Jan 2002 20:11:52 -0000 1.2 +++ WorkerDummy.java 26 Jan 2002 07:25:53 -0000 1.3 @@ -84,19 +84,10 @@ /* ==================== Start/stop ==================== */ - /** Configuration. We'll extract and check the settings. - * XXX We should be able to get info from the same - * properties file as the C side, so port, etc could be - * configured in only one place - */ - public void validate( Properties p ) - { - } - /** Initialize the worker. After this call the worker will be * ready to accept new requests. */ - public void init(WorkerEnv we) throws IOException { + public void init() throws IOException { headersMsgNote=we.getNoteId( WorkerEnv.ENDPOINT_NOTE, "headerMsg" ); } @@ -124,8 +115,8 @@ msg.appendInt(0); - msg.send( ch, ep ); - msg.dump("out:" ); + ch.send( msg, ep ); + // msg.dump("out:" ); msg.reset(); msg.appendByte( HandlerRequest.JK_AJP13_SEND_BODY_CHUNK); @@ -133,13 +124,13 @@ msg.appendBytes( body ); - msg.send(ch, ep); + ch.send(msg, ep); msg.reset(); msg.appendByte( HandlerRequest.JK_AJP13_END_RESPONSE ); msg.appendInt( 1 ); - msg.send(ch, ep ); + ch.send(msg, ep ); } private static final int dL=10;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>