HTTP基础(分析两个例子)
两个例子(一个get,一个post)(一个是访问页面,一个是提交修改后的博文):
preferences.aspx:(header)(文件)
1. Remote Address:42.121.252.58:80
2. Request URL:http://www.cnblogs.com/lamian
3. Request Method:GET
4. Status Code:200 OK
5. Request Headers
- GET /lamian/ HTTP/1.1
- Host: www.cnblogs.com
- Connection: keep-alive
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
- User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.66 Safari/537.36
- Referer:http://i.cnblogs.com/PostDone.aspx?postid=3983497&actiontip=%e4%bf%9d%e5%ad%98%e4%bf%ae%e6%94%b9%e6%88%90%e5%8a%9f (告诉服务器是从哪个页面跳转过来)
- Accept-Encoding: gzip,deflate,sdch
- Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4
- Cookie: __unam=3d91f7a-147ba379df3-3b7be37d-1;
CNZZDATA1000042812=152741559-1410247936-%7C1410247936; SyntaxHighlighter=javascript;
.DottextCookie=B3E0031D9CED2DC8B775A91453AF8C203F532036C245EAC3675BC5CFA4F0AF73B9CCBE266F7BCDBD3F1294E941BC0A43EEC90914DECBDD82C99F02FC99C80A87E1153509A8F5CC207AEC7E274C30B6A89CCE11168973D19DC808E3C3A42043C8E00F1EC8D5604761F78F9F71; AJSTAT_ok_times=1;
__utma=226521935.1598881982.1395737880.1410234138.1411695819.19;
__utmc=226521935; __utmz=226521935.1411695819.19.19.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=HTTP%E4%B8%AD%E7%9A%84get%E5%92%8Cpost%E7%9A%84%E5%8C%BA%E5%88%AB; _ga=GA1.2.1598881982.1395737880; _gat=1
(上网的时候,浏览器寄存在用户电脑的一些个人设置,用来标示用户的个人信息)
If-Modified-Since: Thu, 25 Sep 2014 09:51:04 GMT
6. Response Headers
- HTTP/1.1 200 OK
- Date: Fri, 26 Sep 2014 02:48:17 GMT
- Content-Type: text/html; charset=utf-8
- Transfer-Encoding: chunked
(表示输出的字段大小不能确定,消息体以未定的块组成,并以一个大小为0的块结束。配合Content-Encoding: gzip使用,可以在解析gzip的时候简便不少,就不用申请很大一块字节,可以一块一块来输出,更科学,占用资源更少)
在http1.1的相关规定中,采取了持久链接的解决方案,意思就是说可以在一个TCP链接成功了之后发送多条数据请求和响应。但是这个带来的缺点就是,我必须知道什么时候一个报文什么时候开始,什么时候结束。最简单的应对策略便是使用content-length,但是,这个方法只有在报文长度可以预判的情况下才能起作用。而对于动态的内容或者长度不可知的内容的时候,采用分块(块的大小几乎是一样的)的方法实现传送。
5. Connection: keep-alive
6. Vary: Accept-Encoding
7.Cache-Control: private, max-age=10
private,private、no-cache、must-revalidate表示当再打开新窗口的时候,会重新访问服务器。
max-age=10表示10秒内不会重新访问服务器
8.Expires: Fri, 26 Sep 2014 02:48:24 GMT
缓存失效日期
9.Last-Modified: Fri, 26 Sep 2014 02:48:14 GMT
在浏览器第一次请求某一个URL时,服务器端的返回状态会是200,内容是客户端请求的资源,同时有一个Last-Modified的属性标记此文件在服务期端最后被修改的时间
10.X-UA-Compatible: IE=10
11.Content-Encoding: gzip(使用压缩技术,可以节省流量)
下面是一个post请求:
1. Remote Address:121.199.251.55:80
2. Request URL:http://i.cnblogs.com/EditPosts.aspx?postid=3948833
3. Request Method:POST
4. Status Code:302 Found(网页重定向302为临时性转移)
5. Request Headers
- POST /EditPosts.aspx?postid=3948833 HTTP/1.1
- Host: i.cnblogs.com
- Connection: keep-alive
- Content-Length: 28942
- Cache-Control: max-age=0
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
- Origin: http://i.cnblogs.com
- User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.66 Safari/537.36
- Content-Type: application/x-www-form-urlencoded
- Referer: http://i.cnblogs.com/EditPosts.aspx?postid=3948833
- Accept-Encoding: gzip,deflate
- Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4
- Cookie: __unam=3d91f7a-147ba379df3-3b7be37d-1;
SyntaxHighlighter=javascript;(代码着色工具)
.DottextCookie=B3E0031D9CED2DC8B775A91453AF8C203F532036C245EAC3675BC5CFA4F0AF73B9CCBE266F7BCDBD3F1294E941BC0A43EEC90914DECBDD82C99F02FC99C80A87E1153509A8F5CC207AEC7E274C30B6A89CCE11168973D19DC808E3C3A42043C8E00F1EC8D5604761F78F9F71; .DottextCookie=D83809F6D9D0A42DBB8BA4441B28ECFD06673D66F70CAF34C1A800539F3A7E08D2428219C1CBF1EDF475D14C2F819FBAD5D6E083B69595505E0375BCA46E07ECD7F40A0DDAA292317C4A20A4277CD28590583474FFCD911DAF9CCE9AD84AD99D42BA95C511F2DDB572269DF0; __utma=226521935.1598881982.1395737880.1410234138.1411695819.19;
__utmc=226521935; __utmz=226521935.1411695819.19.19.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=HTTP%E4%B8%AD%E7%9A%84get%E5%92%8Cpost%E7%9A%84%E5%8C%BA%E5%88%AB; _ga=GA1.2.1598881982.1395737880; _gat=1; SERVERID=9b2e527de1fc6430919cfb3051ec3e6c|1411719215|1411719183
Query String Parameters
postid=3948833
1. Form Dataview parsed
下面是一个要提交的表单(修改的博文)意思一下:
__VIEWSTATE=%2………………………………………………24tbPublisTime=2014%2F9%2F1+11%3A04%3A00
2. Response Headers
- HTTP/1.1 302 Found
- Date: Fri, 26 Sep 2014 08:13:36 GMT
- Content-Type: text/html;
- charset=utf-8
- Content-Length: 215
- Connection: keep-alive
- Cache-Control: private (再打开新的页面的时候,会重新访问服务器)
- Location:/PostDone.aspx?postid=3948833&actiontip=%e4%bf%9d%e5%ad%98%e4%bf%ae%e6%94%b9%e6%88%90%e5%8a%9f
- X-AspNet-Version: 4.0.30319 (asp.net是一个技术,这个技术能使得客户端页面上的脚本可以在服务器上运行)
- X-Powered-By: ASP.NET (服务器应用程序支持语言)
- X-UA-Compatible: IE=10
- Set-Cookie: SERVERID=9b2e527de1fc6430919cfb3051ec3e6c|1411719215|1411719183;Path=/