tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java
Date Fri, 29 Jul 2005 10:23:56 GMT
remm        2005/07/29 03:23:56

  Modified:    jk/java/org/apache/coyote/ajp AjpAprProcessor.java
                        LocalStrings.properties AjpMessage.java
               http11/src/java/org/apache/coyote/http11
                        LocalStrings.properties Http11Processor.java
                        Http11AprProcessor.java
               util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Internationalization for the processor classes.
  - Code cleanups.
  - No functional changes.
  
  Revision  Changes    Path
  1.14      +18 -24    jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
  
  Index: AjpAprProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AjpAprProcessor.java	28 Jul 2005 13:48:47 -0000	1.13
  +++ AjpAprProcessor.java	29 Jul 2005 10:23:55 -0000	1.14
  @@ -42,7 +42,6 @@
   import org.apache.tomcat.util.http.HttpMessages;
   import org.apache.tomcat.util.http.MimeHeaders;
   import org.apache.tomcat.util.net.AprEndpoint;
  -import org.apache.tomcat.util.net.SSLSupport;
   import org.apache.tomcat.util.res.StringManager;
   import org.apache.tomcat.util.threads.ThreadWithAttributes;
   
  @@ -67,7 +66,6 @@
       protected static org.apache.commons.logging.Log log
           = org.apache.commons.logging.LogFactory.getLog(AjpAprProcessor.class);
   
  -
       /**
        * The string manager for this package.
        */
  @@ -439,7 +437,7 @@
                   error = true;
                   break;
               } catch (Throwable t) {
  -                log.debug("Error parsing HTTP request", t);
  +                log.debug(sm.getString("ajpprocessor.header.error"), t);
                   // 400 - Bad Request
                   response.setStatus(400);
                   error = true;
  @@ -452,7 +450,7 @@
                   prepareRequest();
                   thrA.setParam(endpoint, request.requestURI());
               } catch (Throwable t) {
  -                log.debug("Error preparing request", t);
  +                log.debug(sm.getString("ajpprocessor.request.prepare"), t);
                   // 400 - Internal Server Error
                   response.setStatus(400);
                   error = true;
  @@ -467,7 +465,7 @@
                   } catch (InterruptedIOException e) {
                       error = true;
                   } catch (Throwable t) {
  -                    log.error("Error processing request", t);
  +                    log.error(sm.getString("ajpprocessor.request.process"), t);
                       // 500 - Internal Server Error
                       response.setStatus(500);
                       error = true;
  @@ -616,11 +614,11 @@
                   jsseCerts =  new X509Certificate[1];
                   jsseCerts[0] = cert;
               } catch(java.security.cert.CertificateException e) {
  -                log.error("Certificate convertion failed" , e );
  +                log.error(sm.getString("ajpprocessor.certs.fail"), e);
                   return;
               }
               
  -            request.setAttribute("javax.servlet.request.X509Certificate", jsseCerts);
  +            request.setAttribute(AprEndpoint.CERTIFICATE_KEY, jsseCerts);
               
           } else if (actionCode == ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE) {
   
  @@ -630,7 +628,7 @@
                       long sa = Address.get(Socket.APR_REMOTE, socket);
                       remoteAddr = Address.getip(sa);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
               request.remoteAddr().setString(remoteAddr);
  @@ -643,7 +641,7 @@
                       long sa = Address.get(Socket.APR_LOCAL, socket);
                       localName = Address.getnameinfo(sa, 0);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
               request.localName().setString(localName);
  @@ -656,7 +654,7 @@
                       long sa = Address.get(Socket.APR_REMOTE, socket);
                       remoteHost = Address.getnameinfo(sa, 0);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
               request.remoteHost().setString(remoteHost);
  @@ -673,7 +671,7 @@
                           localPort = addr.port;
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
   
  @@ -688,7 +686,7 @@
                       Sockaddr addr = Address.getInfo(sa);
                       remotePort = addr.port;
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
               request.setRemotePort(remotePort);
  @@ -705,7 +703,7 @@
                           localPort = addr.port;
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("ajpprocessor.socket.info"), e);
                   }
               }
               request.setLocalPort(localPort);
  @@ -794,7 +792,7 @@
               if(0xA000 == isc) {
                   requestHeaderMessage.getInt(); // To advance the read position
                   hName = Constants.headerTransArray[hId - 1];
  -                vMB = headers.addValue( hName );
  +                vMB = headers.addValue(hName);
               } else {
                   // reset hId -- if the header currently being read
                   // happens to be 7 or 8 bytes long, the code below
  @@ -838,8 +836,6 @@
                   requestHeaderMessage.getBytes(tmpMB);
                   String v = tmpMB.toString();
                   request.setAttribute(n, v);
  -                if (log.isTraceEnabled())
  -                    log.trace("jk Attribute set " + n + "=" + v);
                   break;
               
               case Constants.SC_A_CONTEXT :
  @@ -887,20 +883,20 @@
               case Constants.SC_A_SSL_CIPHER :
                   request.scheme().setString("https");
                   requestHeaderMessage.getBytes(tmpMB);
  -                request.setAttribute(SSLSupport.CIPHER_SUITE_KEY,
  -                                 tmpMB.toString());
  +                request.setAttribute(AprEndpoint.CIPHER_SUITE_KEY,
  +                                     tmpMB.toString());
                   break;
                   
               case Constants.SC_A_SSL_SESSION :
                   request.scheme().setString("https");
                   requestHeaderMessage.getBytes(tmpMB);
  -                request.setAttribute(SSLSupport.SESSION_ID_KEY, 
  -                                  tmpMB.toString());
  +                request.setAttribute(AprEndpoint.SESSION_ID_KEY, 
  +                                     tmpMB.toString());
                   break;
                   
               case Constants.SC_A_SSL_KEY_SIZE :
  -                request.setAttribute(SSLSupport.KEY_SIZE_KEY,
  -                        new Integer(requestHeaderMessage.getInt()));
  +                request.setAttribute(AprEndpoint.KEY_SIZE_KEY,
  +                                     new Integer(requestHeaderMessage.getInt()));
                   break;
   
               // FIXME: no usage for secret attribute here
  @@ -1222,8 +1218,6 @@
               endOfStream = true; // we've read everything there is
           }
           if (endOfStream) {
  -            if( log.isDebugEnabled() ) 
  -                log.debug("refillReadBuffer: end of stream " );
               return false;
           }
   
  
  
  
  1.3       +7 -1      jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/LocalStrings.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalStrings.properties	23 Jun 2005 16:35:27 -0000	1.2
  +++ LocalStrings.properties	29 Jul 2005 10:23:55 -0000	1.3
  @@ -22,3 +22,9 @@
   ajpprotocol.endpoint.resumeerror=Error resuming endpoint
   ajpprotocol.failedread=Socket read failed
   ajpprotocol.failedwrite=Socket write failed
  +
  +ajpprocessor.header.error=Header message parsing failed
  +ajpprocessor.request.prepare=Error preparing request
  +ajpprocessor.request.process=Error processing request
  +ajpprocessor.certs.fail=Certificate convertion failed
  +ajpprocessor.socket.info=Exception getting socket information
  
  
  
  1.3       +93 -85    jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpMessage.java
  
  Index: AjpMessage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpMessage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AjpMessage.java	23 Jun 2005 17:22:13 -0000	1.2
  +++ AjpMessage.java	29 Jul 2005 10:23:55 -0000	1.3
  @@ -36,13 +36,21 @@
    * @author Costin Manolache
    */
   public class AjpMessage {
  +    
       private static org.apache.commons.logging.Log log=
           org.apache.commons.logging.LogFactory.getLog( AjpMessage.class );
   
  -    // that's the original buffer size in ajp13 - otherwise we'll get interoperability
problems.
  -    private byte buf[]=new byte[8*1024]; 
  -    // The current read or write position in the buffer
  +    
  +    /**
  +     * Fixed size buffer.
  +     */
  +    private byte buf[] = new byte[8*1024];
  +    
  +    /**
  +     * The current read or write position in the buffer.
  +     */
       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
  @@ -50,7 +58,6 @@
        * the packet as a whole (counting the header).  Oh, well.
        */
       private int len; 
  -
       
       /**
        * Prepare this packet for accumulating a message from the container to
  @@ -68,13 +75,13 @@
        * the header.  
        */
       public void end() {
  -        len=pos;
  -        int dLen=len-4;
  +        len = pos;
  +        int dLen = len - 4;
   
  -        buf[0] = (byte)0x41;
  -        buf[1] = (byte)0x42;
  -        buf[2]=  (byte)((dLen>>>8 ) & 0xFF );
  -        buf[3] = (byte)(dLen & 0xFF);
  +        buf[0] = (byte) 0x41;
  +        buf[1] = (byte) 0x42;
  +        buf[2] = (byte) ((dLen>>>8) & 0xFF);
  +        buf[3] = (byte) (dLen & 0xFF);
       }
   
       public byte[] getBuffer() {
  @@ -92,19 +99,19 @@
        *
        * @param val The integer to write.
        */
  -    public void appendInt( int val ) {
  -        buf[pos++]   = (byte) ((val >>>  8) & 0xFF);
  +    public void appendInt(int val) {
  +        buf[pos++] = (byte) ((val >>> 8) & 0xFF);
           buf[pos++] = (byte) (val & 0xFF);
       }
   
  -    public void appendByte( int val ) {
  -        buf[pos++] = (byte)val;
  +    public void appendByte(int val) {
  +        buf[pos++] = (byte) val;
       }
   	
  -    public void appendLongInt( int val ) {
  -        buf[pos++]   = (byte) ((val >>>  24) & 0xFF);
  -        buf[pos++] = (byte) ((val >>>  16) & 0xFF);
  -        buf[pos++] = (byte) ((val >>>   8) & 0xFF);
  +    public void appendLongInt(int val) {
  +        buf[pos++] = (byte) ((val >>> 24) & 0xFF);
  +        buf[pos++] = (byte) ((val >>> 16) & 0xFF);
  +        buf[pos++] = (byte) ((val >>> 8) & 0xFF);
           buf[pos++] = (byte) (val & 0xFF);
       }
   
  @@ -116,9 +123,10 @@
        * code, where it saves a round of copying.  A null string is
        * encoded as a string with length 0.  
        */
  -    public void appendBytes(MessageBytes mb) throws IOException {
  -        if(mb==null || mb.isNull() ) {
  -            appendInt( 0);
  +    public void appendBytes(MessageBytes mb)
  +        throws IOException {
  +        if (mb == null || mb.isNull()) {
  +            appendInt(0);
               appendByte(0);
               return;
           }
  @@ -134,32 +142,34 @@
           }
       }
   
  -    public void appendByteChunk(ByteChunk bc) throws IOException {
  -        if(bc==null) {
  +    public void appendByteChunk(ByteChunk bc)
  +        throws IOException {
  +        if (bc == null) {
               log.error("appendByteChunk() null");
  -            appendInt( 0);
  +            appendInt(0);
               appendByte(0);
               return;
           }
   
           byte[] bytes = bc.getBytes();
  -        int start=bc.getStart();
  -        appendInt( bc.getLength() );
  +        int start = bc.getStart();
  +        appendInt(bc.getLength());
           cpBytes(bytes, start, bc.getLength());
           appendByte(0);
       }
   
  -    public void appendCharChunk(CharChunk cc) throws IOException {
  -        if(cc==null) {
  +    public void appendCharChunk(CharChunk cc)
  +        throws IOException {
  +        if(cc == null) {
               log.error("appendByteChunk() null");
  -            appendInt( 0);
  +            appendInt(0);
               appendByte(0);
               return;
           }
   
           int start = cc.getStart();
           int end = cc.getEnd();
  -        appendInt( cc.getLength() );
  +        appendInt(cc.getLength());
           char[] cbuf = cc.getBuffer();
           for (int i = start; i < end; i++) {
               char c = cbuf[i];
  @@ -177,10 +187,11 @@
           appendByte(0);
       }
   
  -    public void appendString(String str) throws IOException {
  -        if(str==null) {
  +    public void appendString(String str)
  +        throws IOException {
  +        if(str == null) {
               log.error("appendByteChunk() null");
  -            appendInt( 0);
  +            appendInt(0);
               appendByte(0);
               return;
           }
  @@ -215,27 +226,25 @@
        * @param off The offset into the array at which to start copying
        * @param numBytes The number of bytes to copy.  
        */
  -    public void appendBytes( byte b[], int off, int numBytes ) {
  -        appendInt( numBytes );
  -        cpBytes( b, off, numBytes );
  +    public void appendBytes(byte b[], int off, int numBytes) {
  +        appendInt(numBytes);
  +        cpBytes(b, off, numBytes);
           appendByte(0);
       }
       
  -    private void cpBytes( byte b[], int off, int numBytes ) {
  -        if( pos + numBytes >= buf.length ) {
  +    private void cpBytes(byte b[], int off, int numBytes) {
  +        if (pos + numBytes >= buf.length) {
               log.error("Buffer overflow: buffer.len=" + buf.length + " pos=" +
  -                      pos + " data=" + numBytes );
  +                      pos + " data=" + numBytes);
               dump("Overflow/coBytes");
  -            log.error( "Overflow ", new Throwable());
  +            log.error("Overflow ", new Throwable());
               return;
           }
  -        System.arraycopy( b, off, buf, pos, numBytes);
  +        System.arraycopy(b, off, buf, pos, numBytes);
           pos += numBytes;
           // buf[pos + numBytes] = 0; // Terminating \0
       }
       
  -
  -    
       // ============ Data Reading Methods ===================
   
       /**
  @@ -248,14 +257,14 @@
           int b1 = buf[pos++] & 0xFF;  // No swap, Java order
           int b2 = buf[pos++] & 0xFF;
   
  -        return  (b1<<8) + b2;
  +        return (b1<<8) + b2;
       }
   
       public int peekInt() {
           int b1 = buf[pos] & 0xFF;  // No swap, Java order
           int b2 = buf[pos+1] & 0xFF;
   
  -        return  (b1<<8) + b2;
  +        return (b1<<8) + b2;
       }
   
       public byte getByte() {
  @@ -270,11 +279,11 @@
   
       public void getBytes(MessageBytes mb) {
           int length = getInt();
  -        if( (length == 0xFFFF) || (length == -1) ) {
  +        if ((length == 0xFFFF) || (length == -1)) {
               mb.recycle();
               return;
           }
  -        mb.setBytes( buf, pos, length );
  +        mb.setBytes(buf, pos, length);
           pos += length;
           pos++; // Skip the terminating \0
       }
  @@ -288,17 +297,17 @@
        */
       public int getBytes(byte dest[]) {
           int length = getInt();
  -        if( length > buf.length ) {
  +        if (length > buf.length) {
               // XXX Should be if(pos + length > buff.legth)?
  -            log.error("getBytes() buffer overflow " + length + " " + buf.length );
  +            log.error("getBytes() buffer overflow " + length + " " + buf.length);
           }
   	
  -        if( (length == 0xFFFF) || (length == -1) ) {
  +        if ((length == 0xFFFF) || (length == -1)) {
               log.info("Null string " + length);
               return 0;
           }
   
  -        System.arraycopy( buf, pos,  dest, 0, length );
  +        System.arraycopy(buf, pos,  dest, 0, length);
           pos += length;
           pos++; // Skip terminating \0  XXX I believe this is wrong but harmless
           return length;
  @@ -328,59 +337,58 @@
       public int processHeader() {
           pos = 0;
           int mark = getInt();
  -        len      = getInt();
  +        len = getInt();
   	    
  -        if( mark != 0x1234 && mark != 0x4142 ) {
  +        if ((mark != 0x1234) && (mark != 0x4142)) {
               // XXX Logging
               log.error("BAD packet signature " + mark);
  -            dump( "In: " );
  +            dump("In: ");
               return -1;
           }
   
  -        if( log.isDebugEnabled() ) 
  -            log.debug( "Received " + len + " " + buf[0] );
  +        if (log.isDebugEnabled()) 
  +            log.debug("Received " + len + " " + buf[0]);
           return len;
       }
       
  -    public void dump(String msg) {
  -        if( log.isDebugEnabled() ) 
  -            log.debug( msg + ": " + buf + " " + pos +"/" + (len + 4));
  -        int max=pos;
  -        if( len + 4 > pos )
  -            max=len+4;
  -        if( max >1000 ) max=1000;
  -        if( log.isDebugEnabled() ) 
  -            for( int j=0; j < max; j+=16 ) 
  -                log.debug( hexLine( buf, j, len ));
  -	
  -    }
  -
       /* -------------------- Utilities -------------------- */
  -    // XXX Move to util package
   
  -    public static String hexLine( byte buf[], int start, int len ) {
  -        StringBuffer sb=new StringBuffer();
  -        for( int i=start; i< start+16 ; i++ ) {
  -            if( i < len + 4)
  -                sb.append( hex( buf[i] ) + " ");
  +    public void dump(String msg) {
  +        if (log.isDebugEnabled()) 
  +            log.debug(msg + ": " + buf + " " + pos +"/" + (len + 4));
  +        int max = pos;
  +        if (len + 4 > pos)
  +            max = len+4;
  +        if (max > 1000)
  +            max = 1000;
  +        if (log.isDebugEnabled()) 
  +            for(int j = 0; j < max; j += 16) 
  +                log.debug(hexLine(buf, j, len));
  +    }
  +
  +    private static String hexLine(byte buf[], int start, int len) {
  +        StringBuffer sb = new StringBuffer();
  +        for (int i = start; i < start + 16 ; i++) {
  +            if (i < len + 4)
  +                sb.append(hex(buf[i]) + " ");
               else 
  -                sb.append( "   " );
  +                sb.append("   ");
           }
           sb.append(" | ");
  -        for( int i=start; i < start+16 && i < len + 4; i++ ) {
  -            if( ! Character.isISOControl( (char)buf[i] ))
  -                sb.append( new Character((char)buf[i]) );
  +        for (int i = start; i < start + 16 && i < len + 4; i++) {
  +            if (!Character.isISOControl((char)buf[i]))
  +                sb.append(new Character((char)buf[i]));
               else
  -                sb.append( "." );
  +                sb.append(".");
           }
           return sb.toString();
       }
   
  -    private  static String hex( int x ) {
  -        //	    if( x < 0) x=256 + x;
  -        String h=Integer.toHexString( x );
  -        if( h.length() == 1 ) h = "0" + h;
  -        return h.substring( h.length() - 2 );
  +    private static String hex(int x) {
  +        String h = Integer.toHexString(x);
  +        if (h.length() == 1) 
  +            h = "0" + h;
  +        return h.substring(h.length() - 2);
       }
   
   }
  
  
  
  1.9       +13 -1     jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/LocalStrings.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LocalStrings.properties	21 Mar 2004 22:37:50 -0000	1.8
  +++ LocalStrings.properties	29 Jul 2005 10:23:56 -0000	1.9
  @@ -30,6 +30,18 @@
   # Http11Processor
   #
   
  +http11processor.regexp.error=Error parsing regular expression {0}
  +http11processor.filter.unknown=Unknown filter {0}
  +http11processor.filter.error=Error intializing filter {0}
  +http11processor.header.parse=Error parsing HTTP request header
  +http11processor.request.prepare=Error preparing request
  +http11processor.request.process=Error processing request
  +http11processor.request.finish=Error finishing request
  +http11processor.response.finish=Error finishing response
  +http11processor.socket.info=Exception getting socket information
  +http11processor.socket.ssl=Exception getting SSL attributes
  +http11processor.socket.timeout=Error setting socket timeout
  +
   #
   # InternalInputBuffer
   #
  
  
  
  1.122     +24 -12    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
  
  Index: Http11Processor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- Http11Processor.java	25 Jul 2005 15:32:48 -0000	1.121
  +++ Http11Processor.java	29 Jul 2005 10:23:56 -0000	1.122
  @@ -35,6 +35,7 @@
   import org.apache.coyote.Request;
   import org.apache.coyote.RequestInfo;
   import org.apache.coyote.Response;
  +import org.apache.coyote.ajp.Constants;
   import org.apache.coyote.http11.filters.ChunkedInputFilter;
   import org.apache.coyote.http11.filters.ChunkedOutputFilter;
   import org.apache.coyote.http11.filters.GzipOutputFilter;
  @@ -52,6 +53,7 @@
   import org.apache.tomcat.util.http.MimeHeaders;
   import org.apache.tomcat.util.net.PoolTcpEndpoint;
   import org.apache.tomcat.util.net.SSLSupport;
  +import org.apache.tomcat.util.res.StringManager;
   import org.apache.tomcat.util.threads.ThreadPool;
   import org.apache.tomcat.util.threads.ThreadWithAttributes;
   
  @@ -70,6 +72,12 @@
       protected static org.apache.commons.logging.Log log
           = org.apache.commons.logging.LogFactory.getLog(Http11Processor.class);
   
  +    /**
  +     * The string manager for this package.
  +     */
  +    protected static StringManager sm =
  +        StringManager.getManager(Constants.Package);
  +
   
       // ----------------------------------------------------------- Constructors
   
  @@ -383,7 +391,7 @@
               noCompressionUserAgents =
                   addREArray(noCompressionUserAgents, nRule);
           } catch (PatternSyntaxException pse) {
  -            log.error("Error parsing regular expression: " + userAgent, pse);
  +            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
           }
       }
   
  @@ -480,10 +488,10 @@
               } else if (obj instanceof OutputFilter) {
                   outputBuffer.addFilter((OutputFilter) obj);
               } else {
  -                log.warn("Unknown filter: " + className);
  +                log.warn(sm.getString("http11processor.filter.unknown", className));
               }
           } catch (Exception e) {
  -            log.error("Error intializing filter: " + className, e);
  +            log.error(sm.getString("http11processor.filter.error", className), e);
           }
       }
   
  @@ -578,7 +586,7 @@
               Pattern nRule = Pattern.compile(userAgent);
               restrictedUserAgents = addREArray(restrictedUserAgents, nRule);
           } catch (PatternSyntaxException pse) {
  -            log.error("Error parsing regular expression: " + userAgent, pse);
  +            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
           }
       }
   
  @@ -802,7 +810,7 @@
               try {
                   socket.setSoTimeout(soTimeout);
               } catch (Throwable t) {
  -                log.debug("Error setting timeout", t);
  +                log.debug(sm.getString("http11processor.socket.timeout"), t);
                   error = true;
               }
           }
  @@ -828,7 +836,9 @@
                   error = true;
                   break;
               } catch (Throwable t) {
  -                log.debug("Error parsing HTTP request", t);
  +                if (log.isDebugEnabled()) {
  +                    log.debug(sm.getString("http11processor.header.parse"), t);
  +                }
                   // 400 - Bad Request
                   response.setStatus(400);
                   error = true;
  @@ -840,7 +850,9 @@
               try {
                   prepareRequest();
               } catch (Throwable t) {
  -                log.debug("Error preparing request", t);
  +                if (log.isDebugEnabled()) {
  +                    log.debug(sm.getString("http11processor.request.prepare"), t);
  +                }
                   // 400 - Internal Server Error
                   response.setStatus(400);
                   error = true;
  @@ -868,7 +880,7 @@
                   } catch (InterruptedIOException e) {
                       error = true;
                   } catch (Throwable t) {
  -                    log.error("Error processing request", t);
  +                    log.error(sm.getString("http11processor.request.process"), t);
                       // 500 - Internal Server Error
                       response.setStatus(500);
                       error = true;
  @@ -883,7 +895,7 @@
               } catch (IOException e) {
                   error = true;
               } catch (Throwable t) {
  -                log.error("Error finishing request", t);
  +                log.error(sm.getString("http11processor.request.finish"), t);
                   // 500 - Internal Server Error
                   response.setStatus(500);
                   error = true;
  @@ -895,7 +907,7 @@
               } catch (IOException e) {
                   error = true;
               } catch (Throwable t) {
  -                log.error("Error finishing response", t);
  +                log.error(sm.getString("http11processor.response.finish"), t);
                   error = true;
               }
   
  @@ -1038,7 +1050,7 @@
                               (SSLSupport.SESSION_ID_KEY, sslO);
                   }
               } catch (Exception e) {
  -                log.warn("Exception getting SSL attributes " ,e);
  +                log.warn(sm.getString("http11processor.socket.ssl"), e);
               }
   
           } else if (actionCode == ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE) {
  @@ -1110,7 +1122,7 @@
                               (SSLSupport.CERTIFICATE_KEY, sslO);
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting SSL Cert",e);
  +                    log.warn(sm.getString("http11processor.socket.ssl"), e);
                   }
               }
           } else if (actionCode == ActionCode.ACTION_REQ_SET_BODY_REPLAY) {
  
  
  
  1.28      +34 -22    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java
  
  Index: Http11AprProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Http11AprProcessor.java	26 Jul 2005 16:39:14 -0000	1.27
  +++ Http11AprProcessor.java	29 Jul 2005 10:23:56 -0000	1.28
  @@ -34,6 +34,7 @@
   import org.apache.coyote.Request;
   import org.apache.coyote.RequestInfo;
   import org.apache.coyote.Response;
  +import org.apache.coyote.ajp.Constants;
   import org.apache.coyote.http11.filters.ChunkedInputFilter;
   import org.apache.coyote.http11.filters.ChunkedOutputFilter;
   import org.apache.coyote.http11.filters.GzipOutputFilter;
  @@ -55,6 +56,7 @@
   import org.apache.tomcat.util.http.FastHttpDateFormat;
   import org.apache.tomcat.util.http.MimeHeaders;
   import org.apache.tomcat.util.net.AprEndpoint;
  +import org.apache.tomcat.util.res.StringManager;
   import org.apache.tomcat.util.threads.ThreadWithAttributes;
   
   
  @@ -72,6 +74,12 @@
       protected static org.apache.commons.logging.Log log
           = org.apache.commons.logging.LogFactory.getLog(Http11AprProcessor.class);
   
  +    /**
  +     * The string manager for this package.
  +     */
  +    protected static StringManager sm =
  +        StringManager.getManager(Constants.Package);
  +
   
       // ----------------------------------------------------------- Constructors
   
  @@ -376,7 +384,7 @@
               noCompressionUserAgents =
                   addREArray(noCompressionUserAgents, nRule);
           } catch (PatternSyntaxException pse) {
  -            log.error("Error parsing regular expression: " + userAgent, pse);
  +            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
           }
       }
   
  @@ -473,10 +481,10 @@
               } else if (obj instanceof OutputFilter) {
                   outputBuffer.addFilter((OutputFilter) obj);
               } else {
  -                log.warn("Unknown filter: " + className);
  +                log.warn(sm.getString("http11processor.filter.unknown", className));
               }
           } catch (Exception e) {
  -            log.error("Error intializing filter: " + className, e);
  +            log.error(sm.getString("http11processor.filter.error", className), e);
           }
       }
   
  @@ -571,7 +579,7 @@
               Pattern nRule = Pattern.compile(userAgent);
               restrictedUserAgents = addREArray(restrictedUserAgents, nRule);
           } catch (PatternSyntaxException pse) {
  -            log.error("Error parsing regular expression: " + userAgent, pse);
  +            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
           }
       }
   
  @@ -790,7 +798,9 @@
                   error = true;
                   break;
               } catch (Throwable t) {
  -                log.debug("Error parsing HTTP request", t);
  +                if (log.isDebugEnabled()) {
  +                    log.debug(sm.getString("http11processor.header.parse"), t);
  +                }
                   // 400 - Bad Request
                   response.setStatus(400);
                   error = true;
  @@ -802,7 +812,9 @@
               try {
                   prepareRequest();
               } catch (Throwable t) {
  -                log.debug("Error preparing request", t);
  +                if (log.isDebugEnabled()) {
  +                    log.debug(sm.getString("http11processor.request.prepare"), t);
  +                }
                   // 400 - Internal Server Error
                   response.setStatus(400);
                   error = true;
  @@ -830,7 +842,7 @@
                   } catch (InterruptedIOException e) {
                       error = true;
                   } catch (Throwable t) {
  -                    log.error("Error processing request", t);
  +                    log.error(sm.getString("http11processor.request.process"), t);
                       // 500 - Internal Server Error
                       response.setStatus(500);
                       error = true;
  @@ -845,7 +857,7 @@
               } catch (IOException e) {
                   error = true;
               } catch (Throwable t) {
  -                log.error("Error finishing request", t);
  +                log.error(sm.getString("http11processor.request.finish"), t);
                   // 500 - Internal Server Error
                   response.setStatus(500);
                   error = true;
  @@ -857,7 +869,7 @@
               } catch (IOException e) {
                   error = true;
               } catch (Throwable t) {
  -                log.error("Error finishing response", t);
  +                log.error(sm.getString("http11processor.response.finish"), t);
                   error = true;
               }
   
  @@ -996,7 +1008,7 @@
                       long sa = Address.get(Socket.APR_REMOTE, socket);
                       remoteAddr = Address.getip(sa);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
               request.remoteAddr().setString(remoteAddr);
  @@ -1009,7 +1021,7 @@
                       long sa = Address.get(Socket.APR_LOCAL, socket);
                       localName = Address.getnameinfo(sa, 0);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
               request.localName().setString(localName);
  @@ -1022,7 +1034,7 @@
                       long sa = Address.get(Socket.APR_REMOTE, socket);
                       remoteHost = Address.getnameinfo(sa, 0);
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
               request.remoteHost().setString(remoteHost);
  @@ -1039,7 +1051,7 @@
                           localPort = addr.port;
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
   
  @@ -1054,7 +1066,7 @@
                       Sockaddr addr = Address.getInfo(sa);
                       remotePort = addr.port;
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
               request.setRemotePort(remotePort);
  @@ -1071,7 +1083,7 @@
                           localPort = addr.port;
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting socket information " ,e);
  +                    log.warn(sm.getString("http11processor.socket.info"), e);
                   }
               }
               request.setLocalPort(localPort);
  @@ -1084,7 +1096,7 @@
                       Object sslO = SSLSocket.getInfoS(socket, SSL.SSL_INFO_CIPHER);
                       if (sslO != null) {
                           request.setAttribute
  -                            ("javax.servlet.request.cipher_suite", sslO);
  +                            (AprEndpoint.CIPHER_SUITE_KEY, sslO);
                       }
                       // Client certificate chain if present
                       int certLength = SSLSocket.getInfoI(socket, SSL.SSL_INFO_CLIENT_CERT_CHAIN);
  @@ -1101,23 +1113,23 @@
                       }
                       if (certs != null) {
                           request.setAttribute
  -                            ("javax.servlet.request.X509Certificate", certs);
  +                            (AprEndpoint.CERTIFICATE_KEY, certs);
                       }
                       // User key size
                       sslO = new Integer(SSLSocket.getInfoI(socket, SSL.SSL_INFO_CIPHER_USEKEYSIZE));
                       if (sslO != null) {
                           request.setAttribute
  -                            ("javax.servlet.request.key_size", sslO);
  +                            (AprEndpoint.KEY_SIZE_KEY, sslO);
                       }
                       // SSL session ID
                       sslO = SSLSocket.getInfoS(socket, SSL.SSL_INFO_SESSION_ID);
                       if (sslO != null) {
                           request.setAttribute
  -                            ("javax.servlet.request.ssl_session", sslO);
  +                            (AprEndpoint.SESSION_ID_KEY, sslO);
                       }
                   }
               } catch (Exception e) {
  -                log.warn("Exception getting SSL attributes " ,e);
  +                log.warn(sm.getString("http11processor.socket.ssl"), e);
               }
   
           } else if (actionCode == ActionCode.ACTION_REQ_SSL_CERTIFICATE) {
  @@ -1148,10 +1160,10 @@
                       }
                       if (certs != null) {
                           request.setAttribute
  -                            ("javax.servlet.request.X509Certificate", certs);
  +                            (AprEndpoint.CERTIFICATE_KEY, certs);
                       }
                   } catch (Exception e) {
  -                    log.warn("Exception getting SSL Cert", e);
  +                    log.warn(sm.getString("http11processor.socket.ssl"), e);
                   }
               }
   
  
  
  
  1.70      +22 -0     jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
  
  Index: AprEndpoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- AprEndpoint.java	27 Jul 2005 15:12:02 -0000	1.69
  +++ AprEndpoint.java	29 Jul 2005 10:23:56 -0000	1.70
  @@ -65,6 +65,28 @@
           StringManager.getManager("org.apache.tomcat.util.net.res");
   
   
  +    /**
  +     * The Request attribute key for the cipher suite.
  +     */
  +    public static final String CIPHER_SUITE_KEY = "javax.servlet.request.cipher_suite";
  +
  +    /**
  +     * The Request attribute key for the key size.
  +     */
  +    public static final String KEY_SIZE_KEY = "javax.servlet.request.key_size";
  +
  +    /**
  +     * The Request attribute key for the client certificate chain.
  +     */
  +    public static final String CERTIFICATE_KEY = "javax.servlet.request.X509Certificate";
  +
  +    /**
  +     * The Request attribute key for the session id.
  +     * This one is a Tomcat extension to the Servlet spec.
  +     */
  +    public static final String SESSION_ID_KEY = "javax.servlet.request.ssl_session";
  +
  +
       // ----------------------------------------------------------------- Fields
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message