1. Request protocol format:
请求首行; //请求方式 请求路径 协议和版本,例如:GET /index.html HTTP/1.1
请求头信息; //请求头名称:请求头内容,即为key:value 格式,例如:Host:localhost
空行; //用来与请求体分隔开
请求体; //GET没有请求体,只有POST有请求体
2. GET request
- The default HTTP request method is GET request
- no request body
- Data must be within 1K
- GET data will be exposed in the browser's address bar
- Common operations for GET requests
- The browser gives the URL directly in the address bar, then it must be a GET request
- Clicking on a hyperlink on a page must also be a GET request
- When submitting a form, the form uses a GET request by default, but can be set to a POST request
- Examples are as follows
GET 127.0.0.1:8090/login HTTP/1.1 <!--GET请求,请求服务器路径为 127.0.0.1:8090/login ,协议为1.1-->
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 <!--当前客户端可以接收的文档类型 q为权重 越大会更倾向于前面-->
Accept-Encoding:gzip, deflate, sdch <!--支持的压缩格式-->
Accept-Language:zh-CN,zh;q=0.8 <!--当前客户端支持的语言-->
Cache-Control:no-cache
Connection:keep-alive <!--客户端支持的链接方式,保持一段时间链接,默认为3000ms-->
Cookie:csrftoken=z5H43ZwARx7AIJ82OEizBOWbsAQA2LPk
Host:127.0.0.1:8090 <!--请求的主机名为localhost-->
Pragma:no-cache
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36 <!--与浏览器和OS相关的信息-->
<!--以下为请求体-->
Name
login/
requests❘737B transferred❘Finish: 5ms❘DOMContentLoaded: 14ms❘Load: 14ms
3. POST request
- Common operations
- Data does not appear in the address bar
- Data cap has no size
- with request body
- If the request body exists in Chinese, it will use URL encoding
- Examples are as follows
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:13 <!--请求体的长度,这里表示13个字节-->
Content-Type:application/x-www-form-urlencoded <!--表单的数据类型-->
Cookie:csrftoken=z5H43ZwARx7AIJ82OEizBOWbsAQA2LPk
Host:127.0.0.1:8090
Origin:http://127.0.0.1:8090
Pragma:no-cache
Referer:http://127.0.0.1:8090/login/ <!--请求来自哪个页面,例如你在百度上点击链接到了这里,那么Referer:http://www.baidu.com;如果你是在浏览器的地址栏中直接输入的地址,那么就没有Referer这个请求头了;-->
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36
Form Data
username:yuan
- The Referer
request header is a more useful request header, which can be used for statistical work and anti-leech.