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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值