URL組成;
image.png
Server + Client + HTTP+DNS:
image.png
請(qǐng)求方式 | 命令 | 請(qǐng)求內(nèi)容 | 響應(yīng)內(nèi)容 |
---|---|---|---|
GET(默認(rèn)) | 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> 后面太長(zhǎng)载迄,省略了…… |
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... |
帶數(shù)據(jù)請(qǐng)求 | 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.. |
... | ... | ... | ... |
請(qǐng)求內(nèi)容格式:
1 動(dòng)詞 路徑 協(xié)議/版本
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 要上傳的數(shù)據(jù)
響應(yīng)內(nèi)容格式:
1 協(xié)議/版本號(hào) 狀態(tài)碼 狀態(tài)解釋
2 Key1: value1
2 Key2: value2
2 Content-Length: 17931
2 Content-Type: text/html
3
4 要下載的內(nèi)容
狀態(tài)碼說明:
- 1xx 不常用
- 2xx 表示成功
- 3xx 表示滾吧
- 4xx 表示你丫錯(cuò)了
- 5xx 表示好吧辅肾,我錯(cuò)了
Chrome中查看響應(yīng)內(nèi)容:
查看 Response Headers,點(diǎn)擊「view source」,你會(huì)看到響應(yīng)的前兩部分
查看 Response 或者 Preview坚冀,你會(huì)看到響應(yīng)的第 4 部分
Request請(qǐng)求頭:
content-type:application/x-www-form-urlencoded
(將中文轉(zhuǎn)譯,,,成UTF-8,,每個(gè)字%隔開)
參考:https://blog.csdn.net/qq_24145735/article/details/50363528?locationNum=13&fps=1