超文本传输协议(HyperText Transfer Protocol)
版本: http/1.0 http/1.1 http/2.0
Request
request line
-
http请求的种类(GETPOSTDELETEPUT...) - 请求资源路径
-
http协议版本
request headers
-
cache-
If-Modified-Since-
If-Modified-Since: Thu, 09 Feb 2012 09:07:57 GMT(时间一致304)
-
-
If-Unmodified-Since-
If-Unmodified-Since: Thu, 09 Feb 2012 09:07:57 GMT(时间一致304)
-
-
If-None-Match-
If-None-Match: "03f2b33c0bfcc1:0"(内容为response中的Etag, 一致304)
-
-
PragmaPragma: no-cache
-
Cache-ControlCache-Control: PublicCache-Control: PrivateCache-Control: no-cache
-
-
Client-
Accept浏览器端可以接受的媒体类型(服务器无法返回该类型, 应返回406 non acceptable)Accept: */*Accept: text/html
-
Accept-Encoding浏览器端申明自己接受的 文件编码, 通常是 压缩方法Accept-Encoding: gzip, deflate
-
Accept-LanguageAccept-Language: en-us
-
User-AgentUser-Agent: Mozilla/4.0......
-
Accept-Charset浏览器申明自己接受的字符集编码Accept-Charset:utf-8
-
TE客户端愿意接受的传输编码,并通知服务器接受接受尾加头信息TE: trailers,deflate;q=0.5
-
-
Cookie/LoginCookie-
Proxy-AuthorizationProxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
-
Entity-
Content-Length常配合Range使用Content-Length: 38
-
RangeRange: bytes: 600-999
-
Content-Type不常出现,一般出现在response头部,用于指定数据文件类型Content-Type: application/x-www-form-urlencoded
-
WarningWarn: 199 Miscellaneous warning
-
-
Miscellaneous-
RefererReferer: http://ce.sysu.edu.cn/hope/
-
-
Transport-
ConnectionConnection: keep-alive:Connection: close:
-
HostHost: ce.sysu.edu.cn
-
UpgradeUpgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
-
ViaVia: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
-
request body
发送给服务器的query信息, GET命令body为空
Response
response line
-
http协议版本 - 状态码 及
message-
200OK -
302Found -
304Not Modified -
400Bad Request -
403Forbidden -
404Not Found -
500Internal Server Error -
503Server Unavailable
-
状态码
-
1XX提示信息 - 表示请求已被成功接收,继续处理 -
2XX成功 - 表示请求已被成功接收,理解,接受 -
3XX重定向 - 要完成请求必须进行更进一步的处理 -
4XX客户端错误 - 请求有语法错误或请求无法实现 -
5XX服务器端错误 - 服务器未能实现合法的请求
response headers
-
cache-
Date生成消息的具体时间和日期Date: Sat, 11 Feb 2012 11:35:14 GMT
-
ExpiresExpires: Tue, 08 Feb 2022 11:35:14 GMT
-
Vary告诉下游代理是使用缓存响应还是从原始服务器请求Vary: Accept-EncodingVary: *
-
Last-ModifiedLast-Modified: Tue, 15 Nov 2010 12:45:26 GMT
-
PragmaPragma: no-cache
-
Age从原始服务器到代理缓存形成的估算时间(以秒计,非负)Age: 12
-
-
Cookie/Login-
P3P跨域设置Cookie, 这样可以解决iframe跨域访问cookie的问题, 兼容IEP3P: CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR
-
Set-CookieSet-Cookie: sc=4c31523a; path=/; domain=.acookie.taobao.com; UserID=JohnDoe; Max-Age=3600; Version=1
-
Proxy-AuthenticateProxy-Authenticate: Basic
-
WWW-Authenticate客户端请求实体类应该使用的授权方案WWW-Authenticate: Basic
-
-
Entity-
ETag和request header的If-None-Match配合使用ETag: "03f2b33c0bfcc1:0"
-
Last-ModifiedLast-Modified: Wed, 21 Dec 2011 09:09:10 GMT
-
Content-TypeContent-Type: text/html; charset=utf-8Content-Type:text/html;charset=GB2312Content-Type: image/jpeg
-
Content-EncodingContent-Encoding:gzip
-
Content-LanguageContent-Language: en-us
-
Content-LanguageContent-Language: en,zh
-
Content-LengthContent-Length: 348
-
Content-LocationContent-Location: /index.htm
-
Content-MD5Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
-
Content-RangeContent-Range: bytes 21010-47021/47022
-
Trailer指出头域在分块传输编码的尾部存在Trailer: Max-Forwards
-
Transfer-Encoding文件传输编码Transfer-Encoding:chunked
-
WarningWarning: 199 Miscellaneous warning
-
Allow-
Allow: POST声明必须用POST方法请求资源, 否则服务器返回405 Method Not Allowed
-
-
-
Miscellaneous-
ServerServer: Microsoft-IIS/7.5
-
X-AspNet-VersionX-AspNet-Version: 4.0.30319
-
X-Powered-ByX-Powered-By: ASP.NET
-
Via告知代理客户端响应是通过哪里发送的Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
-
-
Transport-
ConnectionConnection: keep-aliveConnection: close
-
-
LocationLocation:http://ce.sysu.edu.cn/hope/-
Refresh应用于重定向或一个新的资源被创造,在5秒之后重定向(由网景提出,被大部分浏览器支持)Refresh: 5; url=http:///archives/94.html
-
Retry-After如果实体暂时不可取,通知客户端在指定时间之后再次尝试Retry-After: 120
response body
返回的请求资源主体(数据)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
...
</body>
</html>












网友评论