tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Milstein <dan...@shore.net>
Subject Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Ajp13.java
Date Tue, 27 Feb 2001 22:35:02 GMT
Costin,

Glad I can help out -- I think I see another problem, though.

ll. 379-386 is still dealing with hBuf (which is bound to msg), and will
therefore still overwrite the headers.  I'm attaching a patch which I think
fixes this (I don't have time to test/commit myself at this instant, and
this is a pretty big gotcha):

-Dan

costin@apache.org wrote:
> 
> costin      01/02/26 21:28:08
> 
>   Modified:    src/share/org/apache/tomcat/modules/server Ajp13.java
>   Log:
>   Fix the buffer problem ( need 2 input, one output - not 2 output on input).
> 
>   Thanks again Dan.
> 
>   Revision  Changes    Path
>   1.16      +20 -17    jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java
> 
>   Index: Ajp13.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java,v
>   retrieving revision 1.15
>   retrieving revision 1.16
>   diff -u -r1.15 -r1.16
>   --- Ajp13.java        2001/02/27 03:02:47     1.15
>   +++ Ajp13.java        2001/02/27 05:28:08     1.16
>   @@ -180,11 +180,14 @@
> 
>        OutputStream out;
>        InputStream in;
>   -
>   -    Ajp13Packet outBuf = new Ajp13Packet( MAX_PACKET_SIZE );
>   -    Ajp13Packet inBuf  = new Ajp13Packet( MAX_PACKET_SIZE );
>   +
>   +    // Buffer used of output body and headers
>        OutputBuffer headersWriter=new OutputBuffer(MAX_PACKET_SIZE);
>   -    Ajp13Packet hBuf=new Ajp13Packet(headersWriter);
>   +    Ajp13Packet outBuf = new Ajp13Packet( headersWriter );
>   +    // Buffer used for input body
>   +    Ajp13Packet inBuf  = new Ajp13Packet( MAX_PACKET_SIZE );
>   +    // Boffer used for request head ( and headers )
>   +    Ajp13Packet hBuf=new Ajp13Packet( MAX_PACKET_SIZE );
> 
>        // Holds incoming reads of request body data (*not* header data)
>        byte []bodyBuff = new byte[MAX_READ_SIZE];
>   @@ -230,16 +233,16 @@
>        {
>         // XXX The return values are awful.
> 
>   -     int err = receive(inBuf);
>   +     int err = receive(hBuf);
>         if(err < 0) {
>             return 500;
>         }
> 
>   -     int type = (int)inBuf.getByte();
>   +     int type = (int)hBuf.getByte();
>         switch(type) {
> 
>         case JK_AJP13_FORWARD_REQUEST:
>   -         return decodeRequest(req, inBuf);
>   +         return decodeRequest(req, hBuf);
> 
>         case JK_AJP13_SHUTDOWN:
>             return -2;
>   @@ -495,28 +498,28 @@
>        {
>         // XXX if more headers that MAX_SIZE, send 2 packets!
> 
>   -     hBuf.reset();
>   -        hBuf.appendByte(JK_AJP13_SEND_HEADERS);
>   -        hBuf.appendInt(status);
>   +     outBuf.reset();
>   +        outBuf.appendByte(JK_AJP13_SEND_HEADERS);
>   +        outBuf.appendInt(status);
> 
>   -     hBuf.appendString(HttpMessages.getMessage( status ));
>   +     outBuf.appendString(HttpMessages.getMessage( status ));
> 
>         int numHeaders = headers.size();
>   -        hBuf.appendInt(numHeaders);
>   +        outBuf.appendInt(numHeaders);
> 
>         for( int i=0 ; i < numHeaders ; i++ ) {
>             String headerName = headers.getName(i).toString();
>             int sc = headerNameToSc(headerName);
>                if(-1 != sc) {
>   -                hBuf.appendInt(sc);
>   +                outBuf.appendInt(sc);
>                } else {
>   -                hBuf.appendString(headerName);
>   +                outBuf.appendString(headerName);
>                }
>   -            hBuf.appendString(headers.getValue(i).toString() );
>   +            outBuf.appendString(headers.getValue(i).toString() );
>            }
> 
>   -        hBuf.end();
>   -        send(hBuf);
>   +        outBuf.end();
>   +        send(outBuf);
>        }
> 
>        /**
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org

-- 

Dan Milstein // danmil@shore.net
Mime
View raw message