HTTP request protocol

1. Request protocol format:

请求首行; //请求方式 请求路径 协议和版本,例如:GET /index.html HTTP/1.1
请求头信息; //请求头名称:请求头内容,即为key:value 格式,例如:Host:localhost
空行; //用来与请求体分隔开
请求体; //GET没有请求体,只有POST有请求体

2. GET request

  1. 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
  1. Common operations for GET requests
  2. The browser gives the URL directly in the address bar, then it must be a GET request
  3. Clicking on a hyperlink on a page must also be a GET request
  4. When submitting a form, the form uses a GET request by default, but can be set to a POST request
  5. 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

  1. Common operations
  2. Data does not appear in the address bar
  3. Data cap has no size
  4. with request body
  5. If the request body exists in Chinese, it will use URL encoding
  6. 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
  1. The Referer
    request header is a more useful request header, which can be used for statistical work and anti-leech.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325948262&siteId=291194637