HTTP


四部分: 请求行, 请求头, 空行, 请求数据 请求行: 说明请求类型, 要访问的资源, 以及使用的http版本 请求头: 说明服务器要使用的附加信息 空行: 空行是必须要有的, 即使没有请求数据 请求数据: 也叫主体, 可以添加任意的其他数据 GET /?username=tom&phone=123&email=hello%40qq.com&date=2018-01- 01&sex=male&class=3&rule=on HTTP/1.1 Host: 192.168.26.52:6789 Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/* ;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: zh,zh-CN;q=0.9,en;q=0.8 空行     POST / HTTP/1.1 Host: 192.168.26.52:6789 Connection: keep-alive Content-Length: 84 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 Origin: null Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/* ;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: zh,zh-CN;q=0.9,en;q=0.8  空行 username=tom&phone=123&email=hello%40qq.com&date=2018-01- 01&sex=male&class=3&rule=on       四部分: 状态行, 消息报头, 空行, 响应正文 状态行: 包括http协议版本号, 状态码, 状态信息 消息报头: 说明客户端要使用的一些附加信息 空行: 空行是必须要有的 响应正文: 服务器返回给客户端的文本信息 HTTP/1.1 200 Ok Server: micro_httpd Date: Fri, 18 Jul 2014 14:34:26 GMT /* 告诉浏览器发送的数据是什么类型 */ Content-Type: text/plain; charset=iso-8859-1 (必选项) /* 发送的数据的长度 */ Content-Length: 32 Location:url Content-Language: zh-CN Last-Modified: Fri, 18 Jul 2014 08:36:36 GMT Connection: close   xxxxxxxxxxxxxxxxxxxxxxxxxxxxx服务器给客户端回复的数据

以get发送请求的时候, 服务端收到的请求数据会放在请求行中, 请求数据那一块是空的

post就是上面的方式

用户在发送请求的时候,比如账号中有中文,然后可以在请求头中指定说明这个数据是什么类型的(Content-Type" content="text/html; charset=UTF-8)

然后在服务器就要通过客户端指定的数据类型进行处理