Permalink
Browse files

Add Faces#getUserAgent()

  • Loading branch information...
BalusC committed Jul 28, 2018
1 parent ce5e416 commit ef920bb21ab0a1bf50368c66356f100bd98d3d5f
@@ -1443,6 +1443,18 @@ public static String getRemoteAddr() {
return FacesLocal.getRemoteAddr(getContext());
}
/**
* Returns the User-Agent string of the client.
* <p>
* This is also available in EL as <code>#{faces.userAgent}</code>.
* @return The User-Agent string of the client.
* @see HttpServletRequest#getHeader(String).
* @since 3.2
*/
public static String getUserAgent() {
return FacesLocal.getUserAgent(getContext());
}
/**
* Returns <code>true</code> if connection is secure, <code>false</code> otherwise. This method will first check if
* {@link HttpServletRequest#isSecure()} returns <code>true</code>, and if not <code>true</code>, check if the
@@ -1071,6 +1071,13 @@ public static String getRemoteAddr(FacesContext context) {
return Servlets.getRemoteAddr(getRequest(context));
}
/**
* @see Faces#getUserAgent()
*/
public static String getUserAgent(FacesContext context) {
return Servlets.getUserAgent(getRequest(context));
}
/**
* @see Faces#isRequestSecure()
*/
@@ -401,6 +401,17 @@ public static String getRemoteAddr(HttpServletRequest request) {
return isEmpty(forwardedFor) ? request.getRemoteAddr() : forwardedFor.split("\\s*,\\s*", 2)[0]; // It's a comma separated string: client,proxy1,proxy2,...
}
/**
* Returns the User-Agent string of the client.
* @param request The involved HTTP servlet request.
* @return The User-Agent string of the client.
* @see HttpServletRequest#getHeader(String).
* @since 3.2
*/
public static String getUserAgent(HttpServletRequest request) {
return request.getHeader("User-Agent");
}
/**
* Returns <code>true</code> if connection is secure, <code>false</code> otherwise. This method will first check if
* {@link HttpServletRequest#isSecure()} returns <code>true</code>, and if not <code>true</code>, check if the

0 comments on commit ef920bb

Please sign in to comment.