Package ca.cdr.api.util
Class HttpRequestUtil
java.lang.Object
ca.cdr.api.util.HttpRequestUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getRemoteAddressFromHeaders
(URI theUri, org.springframework.http.HttpHeaders theHeaders, String theDefault) static String
getRemoteAddressOfServletRequest
(jakarta.servlet.http.HttpServletRequest theRequest) Gets the best attempt at the originating client ip address from the incoming HttpServletRequest.
-
Method Details
-
getRemoteAddressOfServletRequest
public static String getRemoteAddressOfServletRequest(jakarta.servlet.http.HttpServletRequest theRequest) Gets the best attempt at the originating client ip address from the incoming HttpServletRequest. NB: Because proxies can remove or change ip addresses (depending on implementation), this cannot be guaranteed to be the originating client ip address. But if the request is made directly, or proxies are handling them in standardized ways, its most likely going to be. In order of priority, this method will prioritize: * Forwarded header as defined in Forwarded spec * X-Forwarded-for header (a standard, but not a spec) * the address on the request itself- Parameters:
theRequest
- - the request- Returns:
- the ip address of the client or first recorded ip address.
-
getRemoteAddressFromHeaders
public static String getRemoteAddressFromHeaders(URI theUri, org.springframework.http.HttpHeaders theHeaders, @Nullable String theDefault)
-