costin      02/04/25 11:27:18

  Modified:    jk/java/org/apache/jk/server JkCoyoteHandler.java
  Log:
  Call sendHeaders() in response ( that will set commited ) instead of directly
  calling the action chain.
  
  Also ( I couldn't resist ) moved the code that serializes the headers in a separate
  ( and more readable ) method.
  
  Revision  Changes    Path
  1.17      +44 -39    
jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java
  
  Index: JkCoyoteHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JkCoyoteHandler.java      24 Apr 2002 23:20:38 -0000      1.16
  +++ JkCoyoteHandler.java      25 Apr 2002 18:27:18 -0000      1.17
  @@ -171,10 +171,9 @@
               // Send the connector a request for commit. The connector should
               // then validate the headers, send them (using sendHeader) and 
               // set the filters accordingly.
  -            res.action(ActionCode.ACTION_COMMIT, null);
  +            res.sendHeaders();
           }
  -        if( log.isInfoEnabled() )
  -            log.info("doWrite " );
  +        if( log.isInfoEnabled() ) log.info("doWrite " );
           MsgContext ep=(MsgContext)res.getNote( epNote );
           
           MsgAjp msg=(MsgAjp)ep.getNote( headersMsgNote );
  @@ -232,6 +231,47 @@
           return OK;
       }
   
  +    private void appendHead(org.apache.coyote.Response res)
  +        throws IOException
  +    {
  +        if( log.isInfoEnabled() )
  +            log.info("COMMIT sending headers " + res + " " + res.getMimeHeaders() );
  +        
  +        C2BConverter c2b=(C2BConverter)res.getNote( utfC2bNote );
  +        if( c2b==null ) {
  +            c2b=new C2BConverter(  "UTF8" );
  +            res.setNote( utfC2bNote, c2b );
  +        }
  +        
  +        MsgContext ep=(MsgContext)res.getNote( epNote );
  +        MsgAjp msg=(MsgAjp)ep.getNote( headersMsgNote );
  +        msg.reset();
  +        msg.appendByte(HandlerRequest.JK_AJP13_SEND_HEADERS);
  +        msg.appendInt( res.getStatus() );
  +        
  +        // s->b conversion, message
  +        msg.appendBytes( null );
  +        
  +        // XXX add headers
  +        
  +        MimeHeaders headers=res.getMimeHeaders();
  +        int numHeaders = headers.size();
  +        msg.appendInt(numHeaders);
  +        for( int i=0; i<numHeaders; i++ ) {
  +            MessageBytes hN=headers.getName(i);
  +            // no header to sc conversion - there's little benefit
  +            // on this direction
  +            c2b.convert ( hN );
  +            msg.appendBytes( hN );
  +                        
  +            MessageBytes hV=headers.getValue(i);
  +            c2b.convert( hV );
  +            msg.appendBytes( hV );
  +        }
  +        ep.setType( JkHandler.HANDLE_SEND_PACKET );
  +        ep.getSource().invoke( msg, ep );
  +    }
  +    
       // -------------------- Coyote Action implementation --------------------
       
       public void action(ActionCode actionCode, Object param) {
  @@ -243,42 +283,7 @@
                       if( log.isInfoEnabled() )
                           log.info("Response already commited " );
                   } else {
  -                    if( log.isInfoEnabled() )
  -                        log.info("COMMIT sending headers " + res + " " + 
res.getMimeHeaders() );
  -                                        
  -                    C2BConverter c2b=(C2BConverter)res.getNote( utfC2bNote );
  -                    if( c2b==null ) {
  -                        c2b=new C2BConverter(  "UTF8" );
  -                        res.setNote( utfC2bNote, c2b );
  -                    }
  -                
  -                    MsgContext ep=(MsgContext)res.getNote( epNote );
  -                    MsgAjp msg=(MsgAjp)ep.getNote( headersMsgNote );
  -                    msg.reset();
  -                    msg.appendByte(HandlerRequest.JK_AJP13_SEND_HEADERS);
  -                    msg.appendInt( res.getStatus() );
  -                    
  -                    // s->b conversion, message
  -                    msg.appendBytes( null );
  -                    
  -                    // XXX add headers
  -                    
  -                    MimeHeaders headers=res.getMimeHeaders();
  -                    int numHeaders = headers.size();
  -                    msg.appendInt(numHeaders);
  -                    for( int i=0; i<numHeaders; i++ ) {
  -                        MessageBytes hN=headers.getName(i);
  -                        // no header to sc conversion - there's little benefit
  -                        // on this direction
  -                        c2b.convert ( hN );
  -                        msg.appendBytes( hN );
  -                        
  -                        MessageBytes hV=headers.getValue(i);
  -                        c2b.convert( hV );
  -                        msg.appendBytes( hV );
  -                    }
  -                    ep.setType( JkHandler.HANDLE_SEND_PACKET );
  -                    ep.getSource().invoke( msg, ep );
  +                    appendHead( res );
                   }
               } else if( actionCode==ActionCode.ACTION_RESET ) {
                   if( log.isInfoEnabled() )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to