URL组成;
![](https://img.haomeiwen.com/i12700303/4b08c0400e907bf5.png)
Server + Client + HTTP+DNS:
![](https://img.haomeiwen.com/i12700303/2d404362d35a0f90.png)
请求方式 | 命令 | 请求内容 | 响应内容 |
---|---|---|---|
GET(默认) | curl -s -v -H "Frank: xxx" -- "https://www.baidu.com" | GET / HTTP/1.1 Host: www.baidu.com User-Agent: curl/7.54.0 Accept: / Frank: xxx | HTTP/1.1 200 OK Accept...Ranges: bytes...<!DOCTYPE html><html> <head> 后面太长,省略了…… |
POST | curl -X POST -s -v -H "Frank: xxx" -- "https://www.baidu.com" | POST / HTTP/1.1 Host: www.baidu.com User-Agent: curl/7.54.0Accept: / | HTTP/1.1 200 OK Accept-Ranges: bytes... |
带数据请求 | curl -s -v -H -d "777" -- "https://www.baidu.com" | POST / HTTP/1.1 Host:www.baidu.com...回车行1234567890 | HTTP/1.1 302 Found...Connection: Keep-AliveContent-Length: 17931.. |
... | ... | ... | ... |
请求内容格式:
1 动词 路径 协议/版本
2 Key1: value1
2 Key2: value2
2 Key3: value3
2 Content-Type: application/x-www-form-urlencoded
2 Host: www.baidu.com
2 User-Agent: curl/7.54.0
3
4 要上传的数据
响应内容格式:
1 协议/版本号 状态码 状态解释
2 Key1: value1
2 Key2: value2
2 Content-Length: 17931
2 Content-Type: text/html
3
4 要下载的内容
状态码说明:
- 1xx 不常用
- 2xx 表示成功
- 3xx 表示滚吧
- 4xx 表示你丫错了
- 5xx 表示好吧,我错了
Chrome中查看响应内容:
查看 Response Headers,点击「view source」,你会看到响应的前两部分
查看 Response 或者 Preview,你会看到响应的第 4 部分
![](https://img.haomeiwen.com/i12700303/02020c18b35b4f64.png)
Request请求头:
content-type:application/x-www-form-urlencoded
(将中文转译,,,成UTF-8,,每个字%隔开)
参考:https://blog.csdn.net/qq_24145735/article/details/50363528?locationNum=13&fps=1
网友评论