什么是http协议
http协议: 对浏览器客户端 和 服务器端 之间数据传输的格式规范
查看http协议的工具
- 使用火狐的firebug插件(右键->firebug->网络)
- 使用谷歌的“审查元素”
- 使用第三方浏览器(右键->审查元素->NetWork)
协议内容
打开工具后,刷新网页会有很多数据出现,随便点击一个,在点Headers选项卡(默认),就会看到HTTP请求的内容了。
Request Headers
我们想查看请求头吧:Request Headers里面的内容
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:www.csdn.net
Referer:
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36
我们挑选几个常用也是重要的部分:
Host
代表你所访问的网站地址
User-Agent
浏览器标识
其他的可以自行查找百度
Response Headers
有请求,就会有响应,如果没有响应那么只能说明服务器抛弃了你的请求,或者服务器没有收到请求
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sat, 17 Mar 2018 15:32:00 GMT
Keep-Alive:timeout=20
Server:openresty
Set-Cookie:TINGYUN_DATA=%7B%22xxxxig1WV1dfhs%23gIMN6oMlwr0%22%2x2%3A%222118521c473d4a7%22%2C%22q%22%3A0%2C%22a%22%3A27%7D
Strict-Transport-Security:max-age=864000
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.23
Content-Encoding
编码方式
Content-Type
响应内容
Server
服务器标识
General
这是最最最常用的
Request URL:
Request Method:GET
Status Code:200 OK
Remote Address:47.95.164.112:443
Request URL
标识当前你访问的内容
Request Method
请求的方法类型
Status
响应的状态 200为正常
Remote Address
远程地址