[b]ANDROID客户端请求[/b]
[b]IOS客户端请求[/b]
[b]解析Headers[/b]
{Accept=[application/json], accept-encoding=[gzip,deflate], accept-language=[zh-CN,en-US;q=0.8], connection=[keep-alive], Content-Length=[51], content-type=[application/json;charset=UTF-8], host=[10.254***:8888], origin=[http://www.***.cn], referer=[http://www.***.cn/***/index.html?showAcitivityIcon=0], user-agent=[Mozilla/5.0 (Linux; Android 4.4.2; PE-TL20 Build/Huawei***) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36], x-requested-with=[com.***], x-wap-profile=[http://wap1.huawei.com/uaprof/HUAWEI_***_UAProfile.xml]}
[b]IOS客户端请求[/b]
{Accept=[application/json], accept-encoding=[gzip, deflate], accept-language=[zh-Hans-CN;q=1], connection=[close], Content-Length=[68], content-type=[application/json], host=[www.***.cn], user-agent=[***/2.5.0 (iPhone; iOS 10.0.2; Scale/2.00)], x-forwarded-for=[10.254***], x-real-ip=[10.254***]}
[b]解析Headers[/b]
public String getHeaders(HttpServletRequest request,String type){
String flag="";
Map<String, String> map=new HashMap<String, String>();
Enumeration<String> headers=request.getHeaderNames();
while (headers.hasMoreElements()) {
String key=(String) headers.nextElement();
String value=request.getHeader(key);
map.put(key, value);
System.out.println("输出key:"+key);
}
if(!map.isEmpty()){
flag=map.get(type);
if(Utils.isNotBlank(flag)){
if(flag.toUpperCase().contains(Enum.DEVICE_TYPE_ANDROID.getCode())){
flag=Enum.DEVICE_TYPE_ANDROID.getCode();
}else if(flag.toUpperCase().contains(Enum.DEVICE_TYPE_IOS.getCode())){
flag=Enum.DEVICE_TYPE_IOS.getCode();
}else{
flag=Enum.DEVICE_TYPE_UNKNOWN.getCode();
}
}
}
System.out.println("结果:"+flag);
return flag;
}