HTTP协议简介
概念
浏览器请求格式
GET / HTTP/1.1
Host: 127.0.0.1:8080
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/78.0.3904.97 Safari/537.36
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
服务器响应格式
HTTP/1.1 200 OK
Bdpagetype: 2
Bdqid: 0xcc6fe58200005258
Cache-Control: private
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html;charset=utf-8
Date: Mon, 11 Nov 2019 13:26:12 GMT
Expires: Mon, 11 Nov 2019 13:26:11 GMT
Server: BWS/1.1
Set-Cookie: BDSVRTM=359; path=/
Set-Cookie: BD_HOME=1; path=/
Set-Cookie: H_PS_PSSID=1449_21104_29567_29700_29220_26350; path=/; domain=.baidu.com
Strict-Transport-Security: max-age=172800
Traceid: 1573478772043835751414731245252660712024
X-Ua-Compatible: IE=Edge,chrome=1
Transfer-Encoding: chunked
<h1>abc</h1>
- 响应头和响应体之间如何区分,响应头是连续的,遇到空行则响应头结束,余下部分为响应体