了解用于http / 2请求和升级的标头HTTP2
我正在编写一个简单的应用程序来确定某些网站是否支持http / 2。
根据我在草案中读到的内容:
https://tools./html/draft-ietf-httpbis-http2-07#section-.2
我应该可以做一个get请求,比如
GET / HTTP/1.1 Host: Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <base64url encoding of HTTP/2 SETTIGS payload>然后,如果他们支持http / 2,响应应该是这样的:
HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: HTTP/2.0 [ HTTP/2.0 connection ...我试图准确理解HTTP2-Settings请求标头的值应该是什么。
我希望有人可以解释一个例子中应该包含哪些信息。
I'm writing a simple app to determine if certain websites support http/2.
Based on what I've read in the draft:
https://tools./html/draft-ietf-httpbis-http2-07#section-.2
I should be able to do a get request such as
GET / HTTP/1.1 Host: Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <base64url encoding of HTTP/2 SETTIGS payload>and then if they support http/2 the respe should be something like:
HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: HTTP/2.0 [ HTTP/2.0 connection ...I'm trying to understand exactly what the value of the HTTP2-Settings request header should be.
I'm hoping someone can explain what information should be included with an example.
最满意答案
HTTP / 2已达到官方标准的状态。
通过使用明文升级机制,您将很难确定网站是否支持HTTP / 2。
原因是浏览器不支持这种升级到HTTP / 2的方式(他们都喜欢使用ALP over TLS),因此两个服务器都不支持。
[免责声明,我是Jetty提交者和Jetty HTTP / 2实现者]。 例如,Jetty确实支持这种升级方式(甚至直接使用HTTP / 2),例如参见这些测试 ,但由于上述原因,我们不会将它部署在我们自己的网站https://上。
您不需要在此升级SETTIGS框架中发送内容,如果您想要在有机会向您回复HTTP / 2之前配置服务器,您只想发送它,但通常默认值是可以的。
请记住,作为连接前言的一部分,客户端必须发送另一个 SETTIGS帧,该帧也可以为空或包含配置参数。 通常,HTTP / 2客户端API(例如Jetty HTTP2Client)将允许您轻松配置作为前言一部分的SETTIGS帧,因为它将在升级机制和ALP机制中使用。
HTTP2-Settings标头的最小有效值是空字符串:
GET / HTTP/1.1 Host: host Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: User-Agent: whatever否则,您需要创建一个SETTIGS帧有效负载(仅此处定义的字节,因此没有在此定义的9个八位字节帧头),然后使用此处定义的base64转换这些字节。
出于测试的目的,可以使用空的HTTP2-Settings标头,但正如我所说,您肯定不会检测网站是否支持HTTP / 2:您的升级将失败,但网站可能会支持HTTP / 2 TLS通过ALP。
HTTP/2 has reached the status of official standard.
You will have very little luck in determining whether websites support HTTP/2 by using the cleartext upgrade mechanism.
The reason is that browsers don't support this style of upgrade to HTTP/2 (they all prefer using ALP over TLS), and therefore neither servers do.
[Disclaimer, I am a Jetty committer and the Jetty HTTP/2 implementor]. For example, Jetty does support this style of upgrade (and even direct HTTP/2), see for example these tests, but we don't deploy it on our own website, https://, for the reas above.
You don't need to send something in this upgrade SETTIGS frame, you want to only send it if you want to configure the server before it gets a chance to speak back HTTP/2 to you, but typically default values are ok.
Remember that, as part of the connection preface, the client has to send another SETTIGS frame, which also can be empty or contain configuration parameters. Typically HTTP/2 client APIs such as the Jetty HTTP2Client will allow you to easily configure the SETTIGS frame that is part of the preface, because it's what will be use in both the upgrade mechanism and the ALP mechanism.
A minimal, valid value for the HTTP2-Settings header is the empty string:
GET / HTTP/1.1 Host: host Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: User-Agent: whateverOtherwise you need to create a SETTIGS frame payload (only the bytes defined here, and hence without the 9 octet frame header defined here), and then convert those bytes using base64 as defined here.
For the purpose of your tests, an empty HTTP2-Settings header will do, but as I said, you will most certainly not detecting whether a website supports HTTP/2: your upgrade will fail, but the website may well support HTTP/2 over TLS via ALP.
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
推荐阅读
留言与评论(共有 8 条评论) |
本站网友 搞笑证件制作 | 19分钟前 发表 |
whatever 否则 | |
本站网友 高级合伙人 | 26分钟前 发表 |
but the website may well support HTTP/2 over TLS via ALP. | |
本站网友 贷款买车需要的手续 | 12分钟前 发表 |
HTTP/1.1 101 Switching Protocols Connection | |
本站网友 鼻翼缩小术 | 22分钟前 发表 |
h2c HTTP2-Settings | |
本站网友 安贞二手房 | 11分钟前 发表 |
Upgrade | |
本站网友 经济危机 | 16分钟前 发表 |
请记住 | |
本站网友 石家庄房产网 | 10分钟前 发表 |
I am a Jetty committer and the Jetty HTTP/2 implementor]. For example |