1. 程式人生 > >webservice 教程學習系列(二)——http 協議

webservice 教程學習系列(二)——http 協議

請求request的組成

(1)請求頭(請求方式(post get) path http1.1)PS:http1.0和http1.1的區別:1.0對於每個資源都需要傳送一次請求,1.1是一次請求可以獲取多個資源。
(2)請求行  
(3)請求體 只有post請求才會有請求體

例如輸入https://www.baidu.com/ 請求request如下所示

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Cookie: BAIDUID=81634667296C9AA00B2BDFD7A446251F:FG=1; BIDUPSID=81634667296C9AA00B2BDFD7A446251F; PSTM=1486793561; MCITY=-131%3A; BDUSS=53RnlPZFQ5aEJ3YXN1QnlabEd5dXpjMmVuczB3SzdvblNZRHdhYzNjQ1ltT2haSVFBQUFBJCQAAAAAAAAAAAEAAABamHRPc21pbGXH2cfZc21pbGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJgLwVmYC8FZdW; BD_UPN=12314353; delPer=0; BD_CK_SAM=1; PSINO=2; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; BDRCVFR[mkUqnUt8juD]=mk3SLVN4HKm; H_PS_645EC=87ca6JkdlEAaHg50l6P63jfDS%2BW2A6rVQP3r0It%2B9fmlqs%2F7eaMaPUlAdUSUvUbAo90XxA; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BD_HOME=1; H_PS_PSSID=1422_21089_18560_27400_26350
Host: www.baidu.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3423.2 Safari/537.36

響應的組成

(1)響應頭(http1.1 響應碼 原因敘述)
(2)響應行
(3)響應體 html文字

Bdpagetype: 2
Bdqid: 0x91d35b1600043826
Cache-Control: private
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html;charset=utf-8
Date: Sun, 18 Nov 2018 06:15:39 GMT
Expires: Sun, 18 Nov 2018 06:15:38 GMT
Server: BWS/1.1
Set-Cookie: BDSVRTM=310; path=/
Set-Cookie: BD_HOME=1; path=/
Set-Cookie: H_PS_PSSID=1422_21089_18560_27400_26350; path=/; domain=.baidu.com
Strict-Transport-Security: max-age=172800
Transfer-Encoding: chunked
X-Ua-Compatible: IE=Edge,chrome=1

一般引數為

Request URL: https://www.baidu.com/
Request Method: GET
Status Code: 200 OK
Remote Address: 61.135.169.121:443
Referrer Policy: no-referrer-when-downgrade