---
title: "http包协议研究"
author: "zzg"
date: "2007-09-04T21:33:25Z"
tags: []
slug: "http"
draft: false
lastmod: "2007-09-04T21:33:25Z"
id: 120342
url: "https://zzg.iteye.com/blog/120342"
---

用IEInspector抓的http包：  
参考http1.1协议，http://www.cnpaf.net/Class/HTTP/0772522080738754597.html

**1.其中的一个ruquest包stream**

xml 代码

 

01. GET http://www.sina.com.cn/iframe/2006/weather/310100.html HTTP/1.1
02. Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, \*/*
03. Referer: http://www.sina.com.cn/
04. Accept-Language: zh-cn
05. UA-CPU: x86
06. Accept-Encoding: gzip, deflate
07. If-Modified-Since: Tue, 04 Sep 2007 01:59:52 GMT
08. If-None-Match: "a1911b-45f-a5153600"
09. User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)
10. Proxy-Connection: Keep-Alive
11. Host: www.sina.com.cn
12. Pragma: no-cache
13. Cookie: sinaGlobalRotator\_http%3A//www.sina.com.cn/=26; rdl\_1\_1=1188899343847; rpb\_1\_0=1188899344037; SINAGLOBAL=210.22.108.98.397911187942276698; SINA\_NEWS\_CUSTOMIZE\_city=%u4E0A%u6D77; vjuids=-1cc3cff55.11496e81190.0.aee5a8a2872e7; vjlast=1188899344; Apache=210.22.108.98.296031188899335707

**2.response相应的包stream**

xml 代码

 

01. HTTP/1.1 200 OK
02. Via: 1.0 HDQSPROXYS01
03. Connection: Keep-Alive
04. Proxy-Connection: Keep-Alive
05. Content-Length: 1119
06. Expires: Tue, 04 Sep 2007 09:52:41 GMT
07. Date: Tue, 04 Sep 2007 09:50:41 GMT
08. Content-Type: text/html
09. ETag: "e0791c-45f-a5153600"
10. Server: Apache/2.0.54 (Unix)
11. Last-Modified: Tue, 04 Sep 2007 01:59:52 GMT
12. Accept-Ranges: bytes
13. Cache-Control: max-age=120
14. Vary: Accept-Encoding
15. X-Cache: MISS from 152-77.sina.com.cn
16. nnCoection: close
17. &lt;html&gt;
18. &lt;head&gt;
19. &lt;title&gt;上海\_天气预报\_新浪首页\_新浪网title&gt;
20. &lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312" /&gt;
21. &lt;meta name="Keywords" content="," /&gt;
22. &lt;meta name="Description" content="此页面的说明" /&gt;
23. &lt;style type="text/css"&gt;
24. body{background: #fff;margin:0;}
25. table,td,img,form{border: none;margin: 0;padding: 0;}
26. td,p,li,select,input,textarea{font-size:12px;}
27. a{text-decoration:underline;}
28. a:link{color:#00007f;}
29. a:visited{color:#00007f;}
30. a:active,a:hover{color:#f00;}
31. --&gt;
32. style&gt;
33. head&gt;
34. &lt;body&gt;
35. &lt;table width="117" cellspacing="0"&gt;
36. &lt;tr align="left"&gt;
37. &lt;td height="18" valign="middle" align="center"&gt;&lt;a href="http://php.weather.sina.com.cn/search.php?city=上海" title="" target="\_blank"&gt;上海a&gt;
38. &lt;img src=http://www.sinaimg.cn/dy/weather/images/figure/midrain\_small.gif width=14 height=14 alt='中雨' align=absmiddle hspace=3&gt;中雨
39. td&gt;
40. tr&gt;
41. table&gt;
42. &lt;table width="117" cellspacing="0" style="line-height:19px;"&gt;
43. &lt;tr align="left"&gt;&lt;td align=center&gt;26℃～24℃td&gt;
44. tr&gt;
45. table&gt;
46. body&gt;
47. html&gt;

**3.相应图片的response流**

xml 代码

 

01. HTTP/1.1 200 OK
02. Via: 1.1 HDQSPROXYS01
03. Connection: Keep-Alive
04. Proxy-Connection: Keep-Alive
05. Content-Length: 35
06. Expires: Sun, 04 Jul 2004 00:04:00 GMT
07. Date: Tue, 04 Sep 2007 09:50:40 GMT
08. Content-Type: image/gif
09. Server: Apache
10. Set-Cookie: vjsid=210.22.108.98.1188899440558079; path=/; expires=Thu, 03-Sep-37 21:50:40 GMT; domain=.wrating.com
11. Accept-Ranges: bytes
12. Pragma: no-cache
13. Cache-Control: no-cache
14. GIF89a

**4.报404时候**

xml 代码

 

01. HTTP/1.1 404 Not Found
02. Date: Tue, 04 Sep 2007 18:00:14 GMT
03. Content-Length: 1214
04. Content-Type: text/html
05. Connection: Close
06. &gt;
07. &lt;HTML&gt;
08. &lt;HEAD&gt;
09. &lt;TITLE&gt;Error 404--Not FoundTITLE&gt;
10. &lt;META NAME="GENERATOR" CONTENT="WebLogic Server"&gt;
11. HEAD&gt;
12. &lt;BODY bgcolor="white"&gt;
13. &lt;FONT FACE=Helvetica&gt;&lt;BR CLEAR=all&gt;
14. &lt;TABLE border=0 cellspacing=5&gt;&lt;TR&gt;&lt;TD&gt;&lt;BR CLEAR=all&gt;
15. &lt;FONT FACE="Helvetica" COLOR="black" SIZE="3"&gt;&lt;H2&gt;Error 404--Not FoundH2&gt;
16. FONT&gt;TD&gt;TR&gt;
17. TABLE&gt;
18. &lt;TABLE border=0 width=100% cellpadding=10&gt;&lt;TR&gt;&lt;TD VALIGN=top WIDTH=100% BGCOLOR=white&gt;&lt;FONT FACE="Courier New"&gt;&lt;FONT FACE="Helvetica" SIZE="3"&gt;&lt;H3&gt;From RFC 2068 &lt;i&gt;Hypertext Transfer Protocol -- HTTP/1.1i&gt;:H3&gt;
19. FONT&gt;&lt;FONT FACE="Helvetica" SIZE="3"&gt;&lt;H4&gt;10.4.5 404 Not FoundH4&gt;
20. FONT&gt;&lt;P&gt;&lt;FONT FACE="Courier New"&gt;The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.p&gt;&lt;p&gt;If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.FONT&gt;P&gt;
21. FONT&gt;TD&gt;TR&gt;
22. TABLE&gt;
23. BODY&gt;
24. HTML&gt;

**5.post时的数据包**

xml 代码

 

01. POST /es/logging.do?method=logon HTTP/1.1
02. Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, \*/*
03. Referer: http://localhost:8080/es/logging.do?method=toLogon
04. Accept-Language: zh-cn
05. Content-Type: application/x-www-form-urlencoded
06. UA-CPU: x86
07. Accept-Encoding: gzip, deflate
08. User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)
09. Host: localhost:8080
10. Content-Length: 57
11. Connection: Keep-Alive
12. Cache-Control: no-cache
13. Cookie: JSESSIONID=AE72735A180C654A598B19E2F000FB26
14. logonName=admin&password=111111&Submit=%E7%99%BB%E5%BD%95

请求包

xml 代码

01. Accept        接收
02. Referer        提交者
03. Accept-Language    接收语言
04. Accept-Encoding 接收编码
05. UA-CPU        用户cpu
06. If-Modified-Since假如修改
07. If-None-Match    假如不匹
08. User-Agent    用户代理
09. Proxy-Connection代理连接
10. Host        主机
11. Pragma        缓存

回应包

xml 代码

 

01. via        路由
02. Content-Length    内容长度
03. Expires        过期
04. Date        日期
05. Content-Type    内容类型
06. ETag        应答报头域提供了请求变量的当前实体标签。
07. Server        服务器类型
08. Last-Modified    最后修改，一缓存条目在最后修改期后未经修改则被认为是有效的.
09. Accept-Ranges    接收范围
10. Cache-Control    缓存控制max-age=120,最大时限（秒）
11. Vary        更正
12. X-Cache        表示你的 http request 是由 proxy server 回的MISS 表 proxy 無資料,代理動作, HIT 表 proxy 直接回應
13. nnCoection