X-Forwarded-For support
This commit is contained in:
parent
b57ee2de7e
commit
3533471d27
|
@ -58,16 +58,18 @@ public class RequestWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* If there is an {@code X-Forwarded-For} header, the <strong>last</strong> entry in that list
|
||||||
|
* is returned instead.
|
||||||
* @see HttpServletRequest#getRemoteAddr()
|
* @see HttpServletRequest#getRemoteAddr()
|
||||||
*/
|
*/
|
||||||
public String getRemoteAddr() {
|
public String getRemoteAddr() {
|
||||||
return request.getRemoteAddr();
|
String addr = request.getHeader("X-Forwarded-For");
|
||||||
}
|
if (null != addr) {
|
||||||
|
final String[] addrs = addr.split(",", -1);
|
||||||
/**
|
addr = addrs[addrs.length - 1];
|
||||||
* @see HttpServletRequest#getRemoteHost()
|
} else {
|
||||||
*/
|
addr = request.getRemoteAddr();
|
||||||
public String getRemoteHost() {
|
}
|
||||||
return request.getRemoteHost();
|
return addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue