org.clazzes.util.http
Class RequestHelper

java.lang.Object
  extended by org.clazzes.util.http.RequestHelper

public abstract class RequestHelper
extends Object

Static helper function for extracting special information from requests.


Constructor Summary
RequestHelper()
           
 
Method Summary
static String getRealRemoteIP(javax.servlet.http.HttpServletRequest request)
          Get the remote IP address of the client taking the X-Forwarded-for header into account.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestHelper

public RequestHelper()
Method Detail

getRealRemoteIP

public static String getRealRemoteIP(javax.servlet.http.HttpServletRequest request)

Get the remote IP address of the client taking the X-Forwarded-for header into account.

If no X-Forwarded-for header is present, the value of ServletRequest.getRemoteAddr() is returned.

If a X-Forwarded-for header is present, the leftmost value in the comma-separated list of X-Forwarded-for-addresses is returned. The rationale for returning the leftmost address is, that this is the original address of the client.

Parameters:
request - A HTTP servlet request.
Returns:
The remote IP address of the client.


Copyright © 2012. All Rights Reserved.