public abstract class RequestUtils extends Object
限定符和类型 | 字段和说明 |
---|---|
static String[] |
CLIENT_IP_HEADERS |
static String |
DEFAULT_IP |
static String[] |
MOBILE_MAPS |
构造器和说明 |
---|
RequestUtils() |
限定符和类型 | 方法和说明 |
---|---|
protected static String |
getAuthority(String scheme,
String host,
int port) |
protected static String |
getClientIp(Function<String,String> function,
String remoteAddr)
获取客户端真实 IP 地址
|
protected static String |
getHost(Function<String,String> function)
获取请求的真实主机地址
|
protected static String |
getScheme(Function<String,String> function)
获取请求的真实 Scheme
|
protected static boolean |
isAjaxRequest(String xRequestedWith)
判断是否为 Ajax 请求
|
protected static boolean |
isMobile(String userAgent,
String accept)
判断是否为移动端请求
|
protected static <T> T |
iteratorRequestHeader(Function<String,T> function,
Function<T,Boolean> validator,
String... headerNames)
遍历获取指定请求头值
|
public static final String[] CLIENT_IP_HEADERS
public static final String[] MOBILE_MAPS
protected static <T> T iteratorRequestHeader(Function<String,T> function, Function<T,Boolean> validator, String... headerNames)
T
- 返回值类型function
- Functionvalidator
- 验证器headerNames
- 请求头名称数组protected static String getScheme(Function<String,String> function)
function
- Functionprotected static String getHost(Function<String,String> function)
function
- Functionprotected static String getClientIp(Function<String,String> function, String remoteAddr)
function
- FunctionremoteAddr
- Remote Addrprotected static boolean isAjaxRequest(String xRequestedWith)
xRequestedWith
- X-Requested-Withprotected static boolean isMobile(String userAgent, String accept)
userAgent
- User-Agentaccept
- AcceptCopyright © 2022 buession.com Inc.. All rights reserved.