http請求中的header

近期梳理python中的urllib/urllib2/httplib等相關庫的時候,發現以前對忽略了一些前端知識點,現在特地補一下。

經典的headers包含"Content-length","Content-type",和其他。結合查看Quick Reference to HTTPHeaders(http://www.cs.tut.fi/~jkorpela/http.html)獲取有用的HTTP頭列表以及它們的解釋意義。然而一堆英文不利於快速掌握這個知識點,好吧,直接來實例,一個key一個key的瞭解吧。打開百度首頁,F12走起,截圖如下:


HOST:

Specifies theInternet host and port number of the resource being requested. Obligatory inall HTTP/1.1 requests.網絡資源的主機和端口地址。

User-Agent [Request]

"Mozilla/5.0 (Windows NT 6.1; WOW64;rv:51.0) Gecko/20100101 Firefox/51.0"

Contains information about the user agent(client) originating the request。包含發起請求的用戶信息,通過這個參數,瀏覽器可以識別客戶使用的操作系統及版本、CPU 類型、瀏覽器及版本、瀏覽器渲染引擎、瀏覽器語言、瀏覽器插件

我這裏是:

Mozilla/5.0,是基於 WebKit 的瀏覽器

Windows NT6.1 ,對應操作系統windows 7

Accept [Request]

Specifies which Internetmedia types are acceptable for the response and to assignpreferences to them.

表示可接受返回的數據類型,任何數據。jpg/gif就表示只能接受jpg/gif類型的數據.

Accept-Language[Request]

Specifies which natural languages areacceptable for the response and to assign preferences to them. Useful for language negotation. 定義頁面語言.

 

Accept-Encoding[Request]

Specifies which data formattranformations, confusingly called content(en)codings, such as compressionmechanisms, are acceptable for the response and to assign preferences to them.

定義數據壓縮格式.

 

Connection     keep-alive表示不要立即斷掉我們的請求.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章