jfarcand    2003/12/02 15:01:01

  Modified:    coyote/src/java/org/apache/coyote Request.java
                        ActionCode.java
               catalina/src/share/org/apache/coyote/tomcat5
                        CoyoteRequest.java
               http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
  Log:
  Add proper getLocalName implementation.
  
  Please review
  
  Revision  Changes    Path
  1.25      +5 -1      
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Request.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Request.java      2 Dec 2003 16:27:11 -0000       1.24
  +++ Request.java      2 Dec 2003 23:01:00 -0000       1.25
  @@ -149,7 +149,7 @@
   
       // remote address/host
       private MessageBytes remoteAddrMB = new MessageBytes();
  -    private MessageBytes localAddr = new MessageBytes();
  +    private MessageBytes localNameMB = new MessageBytes();
       private MessageBytes remoteHostMB = new MessageBytes();
       private MessageBytes localAddrMB = new MessageBytes();
        
  @@ -284,6 +284,10 @@
       public MessageBytes remoteHost() {
        return remoteHostMB;
       }
  +
  +    public MessageBytes localName() {
  +     return localNameMB;
  +    }    
   
       public MessageBytes localAddr() {
        return localAddrMB;
  
  
  
  1.15      +6 -0      
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/ActionCode.java
  
  Index: ActionCode.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/ActionCode.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ActionCode.java   2 Dec 2003 16:27:11 -0000       1.14
  +++ ActionCode.java   2 Dec 2003 23:01:00 -0000       1.15
  @@ -153,6 +153,12 @@
        * Callback for lazy evaluation - local address.
        **/
       public static final ActionCode ACTION_REQ_LOCAL_ADDR_ATTRIBUTE = new 
ActionCode(18);
  +    
  +    
  +    /**
  +     * Callback for lazy evaluation - local address.
  +     **/
  +    public static final ActionCode ACTION_REQ_LOCAL_NAME_ATTRIBUTE = new 
ActionCode(19);
   
       // ----------------------------------------------------------- Constructors
       int code;
  
  
  
  1.25      +23 -5     
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteRequest.java
  
  Index: CoyoteRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteRequest.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CoyoteRequest.java        2 Dec 2003 16:27:11 -0000       1.24
  +++ CoyoteRequest.java        2 Dec 2003 23:01:01 -0000       1.25
  @@ -391,7 +391,13 @@
        * Local address
        */
       protected String localAddr = null;
  +
       
  +    /**
  +     * Local address
  +     */
  +    protected String localName = null;
  +
       /** After the request is mapped to a ServletContext, we can also
        * map it to a logger.
        */ 
  @@ -427,6 +433,7 @@
           remotePort = -1;
           localPort = -1;
           localAddr = null;
  +        localName = null;
   
           attributes.clear();
           notes.clear();
  @@ -654,6 +661,7 @@
           remotePort = -1;
           localPort = -1;
           localAddr = null;
  +        localName = null;
       }
   
   
  @@ -1255,7 +1263,17 @@
        * which the request was received.
        */
       public String getLocalName(){
  -        return getServerName();
  +        if (localName == null) {
  +            if (socket != null) {
  +                InetAddress inet = socket.getLocalAddress();
  +                localAddr = inet.getHostName();
  +            } else {
  +                coyoteRequest.action
  +                    (ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE, coyoteRequest);
  +                localName = coyoteRequest.localName().toString();
  +            }
  +        }
  +        return localName;
       }
   
       /**
  
  
  
  1.92      +21 -2     
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.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- Http11Processor.java      2 Dec 2003 16:27:11 -0000       1.91
  +++ Http11Processor.java      2 Dec 2003 23:01:01 -0000       1.92
  @@ -239,9 +239,17 @@
        * Remote Host associated with the current connection.
        */
       protected String remoteHost = null;
  -
  +    
  +    
       /**
  -     * Remote port to which the socket is connected
  +     * Local Host associated with the current connection.
  +     */
  +    protected String localName = null;
  +    
  +    
  +    
  +    /**
  +     * Local port to which the socket is connected
        */
       protected int localPort = -1;
       
  @@ -1008,7 +1016,18 @@
               }
               request.remoteAddr().setString(remoteAddr);
   
  +        } else if (actionCode == ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE) {
  +            
  +            if ((localName == null) && (socket != null)) {
  +                InetAddress inetAddr = socket.getLocalAddress();
  +                if (inetAddr != null) {
  +                    localName = inetAddr.getHostName();
  +                }
  +            }
  +            request.localName().setString(localName);
  +
           } else if (actionCode == ActionCode.ACTION_REQ_HOST_ATTRIBUTE) {
  +            
               if ((remoteHost == null) && (socket != null)) {
                   InetAddress inetAddr = socket.getInetAddress();
                   if (inetAddr != null) {
  
  
  

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

Reply via email to