HTTP之报文结构

HTTP报文结构

HTTP报文结构

HTTP请求报文

HTTP请求报文由方法、URI、HTTP版本、HTTP首部字段等部分构成


HTTP 请求报文结构

比如我们请求百度(http://www.baidu.com),请求报文如下:

GET / HTTP/1.1
Cookie: sugstore=1; BD_UPN=143254;H_PS_PSSID=1436_21110_29523_29521_29098_29567_29221_26350;    BD_HOME=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598;BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; PSINO=6; delPer=0; BD_CK_SAM=1;   H_PS_645EC=40a1K4LzHHIsWomf9AyDdUkkaWWrAZRSzY92HI%2BOd40d3%2Bq7jQ%2FFuHjfHgfk%2B73G4%2BIo;      COOKIE_SESSION=823_0_9_9_1_10_0_1_9_1_2_2_1566728652_0_0_0_1566729052_0_1566787527%7C9%23261640_54_1566786704%7C9; BDSFRCVID=lhPOJeC629K9pNvwDPd6rZ2JRe-GtSoTH6aok3UtkSHmBvudA5IiEG0Ptx8g0Ku-ewvQogKK3gOTH4PF_2uxOjjg8UtVJeC6EG0P3J; H_BDCLCKID_SF=tJFj_KIyJDvhDRTvhCcjh-FSMgTBKI62aKDsWnnxBhcqEIL4ef4BKMCB5POTKT5HyJrZbJKE3-b6DUbSj4QoMTtA5MRgBPrGbjTb5C5Y2l5nhMJm257JDMP0qfof-qoy523iob3vQpPMVhQ3DRoWXPIqbN7P-p5Z5mAqKl0MLIOkbRO4-TF5D63QDx5; MCITY=-138%3A340%3A; BDUSS=9pfm5JVk9IQ3drMFR4ZHVCflFqMFI1Uzc1bW1LZXp0VjNLLThhSzlqRmx4bzFaSVFBQUFBJCQAAAAAAAAAAAEAAACAHvsHd2lsbGFiaWxpdHkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGU5ZlllOWZZYW; PSTM=1432975522; BIDUPSID=082C42C5804A9063EA87749B424B7E1C; BAIDUID=082C42C5804A9063EA87749B424B7E1C:FG=1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Host: www.baidu.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6)     AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15
Accept-Language: zh-cn
Accept-Encoding: br, gzip, deflate
Connection: keep-alive

HTTP响应报文

HTTP响应报文由HTTP版本、状态码(数字和原因短语)、HTTP首部字段构成


HTTP 响应报文结构

下面是请求百度之后的响应报文:

HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Set-Cookie: BDSVRTM=246; path=/
Set-Cookie: BD_HOME=1; path=/
Set-Cookie: H_PS_PSSID=1436_21110_29523_29521_29098_29567_29221_26350; path=/; domain=.baidu.com
Content-Encoding: gzip
Expires: Mon, 26 Aug 2019 04:27:30 GMT
Transfer-Encoding: Identity
Cache-Control: private
Date: Mon, 26 Aug 2019 04:27:31 GMT
Connection: Keep-Alive
Server: BWS/1.1
Bdqid: 0xc718c96f0007f7ef
Bdpagetype: 2
Strict-Transport-Security: max-age=172800
X-Ua-Compatible: IE=Edge,chrome=1

你可能感兴趣的:(HTTP之报文结构)