You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by hg...@apache.org on 2001/05/15 11:50:38 UTC

cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade HttpServletRequestFacade.java

hgomez      01/05/15 02:50:38

  Modified:    src/facade22/org/apache/tomcat/facade
                        HttpServletRequestFacade.java
  Log:
  Fix the getRemoteHost() bugs for both ajp12/ajp13....
  
  Revision  Changes    Path
  1.23      +14 -1     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- HttpServletRequestFacade.java	2001/04/28 18:39:11	1.22
  +++ HttpServletRequestFacade.java	2001/05/15 09:50:37	1.23
  @@ -346,7 +346,20 @@
       }
   
       public String getRemoteHost() {
  -        return request.remoteHost().toString();
  +		String remoteHost = request.remoteHost().toString();
  +
  +        // AJP12 defaults to empty string, AJP13 defaults to null
  +        if(remoteHost != null && remoteHost.length() != 0)
  +            return remoteHost;
  +
  +        try{
  +            remoteHost = InetAddress.getByName(request.remoteAddr().toString()).getHostName();
  +        }catch(Exception e){
  +            // If anything went wrong then fall back to using the remote hosts IP address
  +            remoteHost = request.remoteAddr().toString();
  +        }
  +
  +        return remoteHost;
       }
   
       public String getRequestURI() {