tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfarc...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core DummyRequest.java
Date Wed, 05 Mar 2003 02:31:48 GMT
jfarcand    2003/03/04 18:31:47

  Modified:    coyote/src/java/org/apache/coyote Request.java
               coyote/src/java/org/apache/coyote/tomcat5 CoyoteRequest.java
               http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
               catalina/src/share/org/apache/catalina/connector
                        RequestFacade.java
               catalina/src/share/org/apache/catalina/core
                        DummyRequest.java
  Log:
  Servlet 2.4 new features:
  
  ===================================================
  Add the following methods in ServletRequest, SRV.14.2.16.1.
  
        public int getRemotePort()
               Returns the Internet Protocol (IP) source port of the client
               or last proxy that sent the request.
  
        public java.lang.String getLocalName()
               Returns the host name of the Internet Protocol (IP) interface on
               which the request was received.
  
        public java.lang.String getLocalAddr()
               Returns the Internet Protocol (IP) address of the interface on
               which the request  was received.
  
        public int getLocalPort()
               Returns the Internet Protocol (IP) port number of the interface
               on which the request was received.
  ===================================================
  
  Please review the patch and let me know if it brokes other Connectors.
  
  Specifically, is ActionCode.ACTION_REQ_HOST_ATTRIBUTE is an appropriate hook event or should
I create one specifically for localAddr and localPort?
  
  Revision  Changes    Path
  1.19      +18 -2     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Request.java	20 Jan 2003 23:45:11 -0000	1.18
  +++ Request.java	5 Mar 2003 02:31:47 -0000	1.19
  @@ -134,6 +134,8 @@
       private MessageBytes serverNameMB = new MessageBytes();
   
       private String localHost;
  +    
  +    private int remotePort;
   
       private MessageBytes schemeMB = new MessageBytes();
   
  @@ -146,8 +148,10 @@
   
       // remote address/host
       private MessageBytes remoteAddrMB = new MessageBytes();
  +    private MessageBytes localAddr = new MessageBytes();
       private MessageBytes remoteHostMB = new MessageBytes();
  -    
  +    private MessageBytes localAddrMB = new MessageBytes();
  +     
       private MimeHeaders headers = new MimeHeaders();
   
       private MessageBytes instanceId = new MessageBytes();
  @@ -280,12 +284,24 @@
   	return remoteHostMB;
       }
   
  +    public MessageBytes localAddr() {
  +	return localAddrMB;
  +    }
  +    
       public String getLocalHost() {
   	return localHost;
       }
   
       public void setLocalHost(String host) {
   	this.localHost = host;
  +    }    
  +    
  +    public int getRemotePort(){
  +        return remotePort;
  +    }
  +        
  +    public void setRemotePort(int port){
  +        this.remotePort = port;
       }
   
   
  @@ -493,7 +509,7 @@
           parameters.recycle();
   
           unparsedURIMB.recycle();
  -        uriMB.recycle();
  +        uriMB.recycle(); 
           decodedUriMB.recycle();
   	queryMB.recycle();
   	methodMB.recycle();
  
  
  
  1.21      +70 -5     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteRequest.java
  
  Index: CoyoteRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteRequest.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CoyoteRequest.java	30 Jan 2003 18:22:58 -0000	1.20
  +++ CoyoteRequest.java	5 Mar 2003 02:31:47 -0000	1.21
  @@ -374,7 +374,17 @@
        */
       protected String remoteHost = null;
   
  -
  +    
  +    /**
  +     * Remote port
  +     */
  +    protected int remotePort = -1;
  +    
  +    /**
  +     * Local address
  +     */
  +    protected String localAddr = null;
  +    
       // --------------------------------------------------------- Public Methods
   
   
  @@ -402,6 +412,8 @@
           secure = false;
           remoteAddr = null;
           remoteHost = null;
  +        remotePort = -1;
  +        localAddr = null;
   
           attributes.clear();
           notes.clear();
  @@ -622,6 +634,8 @@
           this.socket = socket;
           remoteHost = null;
           remoteAddr = null;
  +        remotePort = -1;
  +        localAddr = null;
       }
   
   
  @@ -1172,7 +1186,58 @@
           return remoteHost;
       }
   
  +    /**
  +     * Returns the Internet Protocol (IP) source port of the client
  +     * or last proxy that sent the request.
  +     */    
  +    public int getRemotePort(){
  +        if (remotePort == -1) {
  +            if (socket != null) {
  +                remotePort = socket.getPort();
  +            } else {
  +                coyoteRequest.action
  +                    (ActionCode.ACTION_REQ_HOST_ATTRIBUTE, coyoteRequest);
  +                remotePort = coyoteRequest.getRemotePort();
  +            }
  +        }
  +        return remotePort;    
  +    }
  +
  +    /**
  +     * Returns the host name of the Internet Protocol (IP) interface on
  +     * which the request was received.
  +     */
  +    public String getLocalName(){
  +        return getServerName();
  +    }
  +
  +    /**
  +     * Returns the Internet Protocol (IP) address of the interface on
  +     * which the request  was received.
  +     */       
  +    public String getLocalAddr(){
  +        if (localAddr == null) {
  +            if (socket != null) {
  +                InetAddress inet = socket.getLocalAddress();
  +                localAddr = inet.getHostAddress();
  +            } else {
  +                coyoteRequest.action
  +                    (ActionCode.ACTION_REQ_HOST_ATTRIBUTE, coyoteRequest);
  +                localAddr = coyoteRequest.localAddr().toString();
  +            }
  +        }
  +        return localAddr;    
  +    }
  +
   
  +    /**
  +     * Returns the Internet Protocol (IP) port number of the interface
  +     * on which the request was received.
  +     */
  +    public int getLocalPort(){
  +        return getServerPort();
  +    }
  +    
       /**
        * Return a RequestDispatcher that wraps the resource at the specified
        * path, which may be interpreted as relative to the current request path.
  
  
  
  1.59      +22 -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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- Http11Processor.java	29 Jan 2003 12:43:26 -0000	1.58
  +++ Http11Processor.java	5 Mar 2003 02:31:47 -0000	1.59
  @@ -236,7 +236,18 @@
        */
       protected String remoteHost = null;
   
  -
  +    
  +    /**
  +     * Remote port to which the socket is connected
  +     */
  +    protected int remotePort = -1;
  +    
  +    
  +    /**
  +     *
  +     */
  +    protected String localAddr = null; 
  +    
       /**
        * Maximum timeout on uploads.
        */
  @@ -561,6 +572,8 @@
           // Set the remote address
           remoteAddr = null;
           remoteHost = null;
  +        localAddr = null;
  +        remotePort = -1;
   
           // Setting up the I/O
           inputBuffer.setInputStream(input);
  @@ -783,6 +796,14 @@
               if (remoteHost == null) {
                   remoteHost = socket.getInetAddress().getHostName();
                   request.remoteHost().setString(remoteHost);
  +            }           
  +            if (remotePort == -1){
  +                remotePort = socket.getPort();
  +                request.setRemotePort(remotePort);
  +            }            
  +            if (localAddr == null){
  +               localAddr = socket.getLocalAddress().getHostAddress();
  +               request.localAddr().setString(localAddr);
               }
   
           } else if (actionCode == ActionCode.ACTION_REQ_SSL_CERTIFICATE) {
  @@ -1008,7 +1029,6 @@
               InetAddress localAddress = socket.getLocalAddress();
               // Setting the socket-related fields. The adapter doesn't know 
               // about socket.
  -            request.setLocalHost(localAddress.getHostName());
               request.serverName().setString(localAddress.getHostName());
               return;
           }
  
  
  
  1.2       +37 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/RequestFacade.java
  
  Index: RequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/RequestFacade.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestFacade.java	18 Jul 2002 16:47:57 -0000	1.1
  +++ RequestFacade.java	5 Mar 2003 02:31:47 -0000	1.2
  @@ -85,6 +85,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  + * @author Jean-Francois Arcand
    * @version $Revision$ $Date$
    */
   
  @@ -258,5 +259,37 @@
           return request.getRealPath(path);
       }
   
  +    /**
  +     * Returns the Internet Protocol (IP) source port of the client
  +     * or last proxy that sent the request.
  +     */    
  +    public int getRemotePort(){
  +        return request.getRemotePort();
  +    }
  +
  +
  +    /**
  +     * Returns the host name of the Internet Protocol (IP) interface on
  +     * which the request was received.
  +     */
  +    public String getLocalName(){
  +        return request.getLocalName();
  +    }
   
  +    /**
  +     * Returns the Internet Protocol (IP) address of the interface on
  +     * which the request  was received.
  +     */       
  +    public String getLocalAddr(){
  +        return request.getLocalAddr();
  +    }
  +
  +    
  +    /**
  +     * Returns the Internet Protocol (IP) port number of the interface
  +     * on which the request was received.
  +     */
  +    public int getLocalPort(){
  +        return request.getLocalPort();
  +    }
   }
  
  
  
  1.8       +9 -6      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/DummyRequest.java
  
  Index: DummyRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/DummyRequest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DummyRequest.java	30 Jan 2003 00:04:28 -0000	1.7
  +++ DummyRequest.java	5 Mar 2003 02:31:47 -0000	1.8
  @@ -346,7 +346,10 @@
       public boolean isRequestedSessionIdValid() { return false; }
       public boolean isUserInRole(String role) { return false; }
       public Principal getUserPrincipal() { return null; }
  -
  -
  +    public String getLocalAddr() { return null; }    
  +    public String getLocalName() { return null; }
  +    public int getLocalPort() { return -1; }
  +    public int getRemotePort() { return -1; }
  +    
   }
   
  
  
  

---------------------------------------------------------------------
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