The AJAX request (asynchronized) differs from the message header (header) of the normal request (synchronized):
String Reqtype = Request.getheader ("X-requested-with"), if (null = = Reqtype) {//normal request}else if (Reqtype.equals (" XMLHttpRequest ")) {//ajax Request}
1. Request headers
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
accept-encoding: gzip, deflate, SDCH
accept-language: zh-cn,zh;q=0.8,en;q=0.6
Connection: keep-alive
Cookie: bd_home=0; bd_upn=12314353; Baiduid=6d80ec15fb3f7d55f6cf21531b4789a2:fg=1
Host: www.baidu.com
Referer: http://news.baidu.com/
upgrade-insecure-requests: 1
user-agent: mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/47.0.2526.106 safari/537.36
Response headers
Bdpagetype: 1
bdqid: 0xcc5e27ca0001088a
Bduserid: 0
Cache-control:p rivate
Connection: keep-alive
content-encoding: gzip
content-type: text/html; Charset=utf-8
cxy_all: baidu+1e0afc7905a9c9dcea7d6f252627f95b
Date: Fri, 06:35:43 GMT
Expires: Fri, 06:35:22 GMT
Server: bfe/1.0.8.14
Set-cookie:P stm=1462516543; Expires=thu, 31-dec-37 23:55:55 GMT; max-age=2147483647; path=/; Domain=.baidu.com
Set-cookie: __bsi=17208040824016918998_00_2870_r_n_6_0303_c02f_n_i_i_0; Expires=fri, 06-may-16 06:35:48 GMT; domain=www.baidu.com; path=/
Set-cookie: h_ps_pssid=1442_19713_18281_19805_19899_19559_19807_19843_19902_19861_17001_15263_12288; path=/; Domain=.baidu.com
Set-cookie: BIDUPSID=6D80EC15FB3F7D55F6CF21531B4789A2; Expires=thu, 31-dec-37 23:55:55 GMT; max-age=2147483647; path=/; Domain=.baidu.com
Set-cookie: bd_home=0; path=/
Set-cookie: bdsvrtm=0; path=/
transfer-encoding: chunked
Vary: accept-encoding
x-powered-by: hphp
x-ua-compatible: ie=edge,chrome=1
2. Ajax Asynchronous Request headers
Accept: Text/javascript, Application/javascript, Application/ecmascript, Application/x-ecmascript, */*; q=0.01
accept-encoding: gzip, deflate, SDCH
accept-language: zh-cn,zh;q=0.8,en;q=0.6
Connection: keep-alive
Cookie: baiduid=6d80ec15fb3f7d55f6cf21531b4789a2:fg=1; pstm=1462516543; bd_home=0; h_ps_pssid=1442_19713_18281_19805_19899_19559_19807_19843_19902_19861_17001_15263_12288; __bsi=17208040824016918998_00_2870_r_n_6_0303_c02f_n_i_i_0; bidupsid=5081a970dd87c74cffbadf0b28a1af39; bd_upn=12314353
Host: www.baidu.com
Referer: https://www.baidu.com/
user-agent: mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/47.0.2526.106 safari/537.36
x-requested-with: XMLHttpRequest
Ajax Asynchronous Response Headers
Cache-control:p rivate
Connection: keep-alive
content-length: 95
content-type: Baiduapp/json; v6.27.2.14; Charset=utf-8
Date: Fri, 06:35:45 GMT
Expires: Fri, 07:35:45 GMT
Server: bfe/1.0.8.14
Set-cookie: __bsi=16943568347195085118_00_0_i_r_1_0303_c02f_n_i_i_0; Expires=fri, 06-may-16 06:35:50 GMT; domain=www.baidu.com; path=/
Ajax Request VS Normal request