@Test public void extractClientIp_X_FORWARDED_FOR() { when(request.getHeader("X-FORWARDED-FOR")).thenReturn("12.12.12.12"); assertEquals("12.12.12.12", HttpServletRequestUtils.extractClientIp(request)); }
public static String extractClientIp(HttpServletRequest request) { Preconditions.checkNotNull(request); String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; }
HttpServletRequestUtils { public static String extractClientIp(HttpServletRequest request) { Preconditions.checkNotNull(request); String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; } }
HttpServletRequestUtils { public static String extractClientIp(HttpServletRequest request) { Preconditions.checkNotNull(request); String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; } private  HttpServletRequestUtils(); }
HttpServletRequestUtils { public static String extractClientIp(HttpServletRequest request) { Preconditions.checkNotNull(request); String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; } private  HttpServletRequestUtils(); static String extractClientIp(HttpServletRequest request); static String extractScheme(HttpServletRequest request); static String extractHost(HttpServletRequest request); static int extractServerPort(HttpServletRequest request); static String constructRequestBaseUrl(HttpServletRequest request); static String constructRequestUrl(HttpServletRequest request); static String constructRequestUrlWithParameters(HttpServletRequest request); static boolean isDefaultPort(String scheme, int port); }
HttpServletRequestUtils { public static String extractClientIp(HttpServletRequest request) { Preconditions.checkNotNull(request); String ipAddress = request.getHeader("X-FORWARDED-FOR"); if (ipAddress == null) { ipAddress = request.getRemoteAddr(); } return ipAddress; } private  HttpServletRequestUtils(); static String extractClientIp(HttpServletRequest request); static String extractScheme(HttpServletRequest request); static String extractHost(HttpServletRequest request); static int extractServerPort(HttpServletRequest request); static String constructRequestBaseUrl(HttpServletRequest request); static String constructRequestUrl(HttpServletRequest request); static String constructRequestUrlWithParameters(HttpServletRequest request); static boolean isDefaultPort(String scheme, int port);  }