ajax request VS normal request

前端之家收集整理的这篇文章主要介绍了ajax request VS normal request前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

ajax请求(asynchronized)与普通请求(synchronized)的报文头(Header)不同:

StringreqType=request.getHeader("X-Requested-With");
if(null==reqType){//normalrequest}
elseif(reqType.equals("XMLHttpRequest")){//ajaxrequest}

1、request headers

  1. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

  2. Accept-Encoding:gzip,deflate,sdch

  3. Accept-Language:zh-CN,zh;q=0.8,en;q=0.6

  4. Connection:keep-alive

  5. Cookie:BD_HOME=0; BD_UPN=12314353; BAIDUID=6D80EC15FB3F7D55F6CF21531B4789A2:FG=1

  6. Host:www.baidu.com

  7. Referer:http://news.baidu.com/

  8. Upgrade-Insecure-Requests:1

  9. 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

  1. BDPAGETYPE:1

  2. BDQID:0xcc5e27ca0001088a

  3. BDUSERID:0

  4. Cache-Control:private

  5. Connection:keep-alive

  6. Content-Encoding:gzip

  7. Content-Type:text/html; charset=utf-8

  8. Cxy_all:baidu+1e0afc7905a9c9dcea7d6f252627f95b

  9. Date:Fri,06 May 2016 06:35:43 GMT

  10. Expires:Fri,06 May 2016 06:35:22 GMT

  11. Server:bfe/1.0.8.14

  12. Set-Cookie:PSTM=1462516543; expires=Thu,31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

  13. 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=/

  14. Set-Cookie:H_PS_PSSID=1442_19713_18281_19805_19899_19559_19807_19843_19902_19861_17001_15263_12288; path=/; domain=.baidu.com

  15. Set-Cookie:BIDUPSID=6D80EC15FB3F7D55F6CF21531B4789A2; expires=Thu,31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

  16. Set-Cookie:BD_HOME=0; path=/

  17. Set-Cookie:BDSVRTM=0; path=/

  18. Transfer-Encoding:chunked

  19. Vary:Accept-Encoding

  20. X-Powered-By:HPHP

  21. X-UA-Compatible:IE=Edge,chrome=1

2、Ajax异步request headers

  1. Accept:text/javascript,application/javascript,application/ecmascript,application/x-ecmascript,*/*; q=0.01

  2. Accept-Encoding:gzip,en;q=0.6

  3. Connection:keep-alive

  4. 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

  5. Host:www.baidu.com

  6. Referer:https://www.baidu.com/

  7. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/47.0.2526.106 Safari/537.36

  8. X-Requested-With:XMLHttpRequest

Ajax异步response headers

  1. Cache-Control:private

  2. Connection:keep-alive

  3. Content-Length:95

  4. Content-Type:baiduApp/json; v6.27.2.14; charset=UTF-8

  5. Date:Fri,06 May 2016 06:35:45 GMT

  6. Expires:Fri,06 May 2016 07:35:45 GMT

  7. Server:bfe/1.0.8.14

  8. 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=/

原文链接:https://www.f2er.com/ajax/162214.html

猜你在找的Ajax相关文章