http请求中的header

来源:互联网 发布:淘宝刷收藏怎么算的 编辑:程序博客网 时间:2024/05/16 07:05

近期梳理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 forlanguage 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表示不要立即断掉我们的请求.

 

0 0
原创粉丝点击