HTTP2中应该是什么连接消息标头?
我发现获取消息头看起来像:
:method: GET
:scheme: https
:authority: server.net
:path: /config
accept: */*
accept-encoding: gzip,deflate
What a connect message header should look like?
这个例子来自http2的RFC:
GET /resource HTTP/1.1 HEADERS
Host: example.org ==> + END_STREAM
Accept: image/jpeg + END_HEADERS
:method = GET
:scheme = https
:path = /resource
host = example.org
accept = image/jpeg
我想知道http2中connect头的等效项。 在Http1中是:
CONNECT example.org:443 HTTP/1.1
Host: example.org:443
I found that a get message header looks like:
:method: GET
:scheme: https
:authority: server.net
:path: /config
accept: */*
accept-encoding: gzip,deflate
What a connect message header should look like?
This example is from the RFC of http2:
GET /resource HTTP/1.1 HEADERS
Host: example.org ==> + END_STREAM
Accept: image/jpeg + END_HEADERS
:method = GET
:scheme = https
:path = /resource
host = example.org
accept = image/jpeg
I want to know the equivalent of the connect header in http2.
In Http1 is:
CONNECT example.org:443 HTTP/1.1
Host: example.org:443
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP/2 中的
CONNECT
方法的格式在 第 8.3 节。上面使用的格式如下所示:
根据指定,
:scheme
和:path
必须 被省略。HTTP/2
CONNECT
方法还可用于引导其他协议(例如,请参阅 WebSocket over HTTP/2),因此,此外,:protocol
伪标头也可能存在。但请记住,这只是 HTTP/2 的文本表示;实际通过网络传输的字节是不同的,因为您必须使用 HPACK 对它们进行编码。
除非您实际上正在编写 HTTP/2 实现,否则最好使用现有库(几乎可以在任何编程语言中使用)发送 HTTP/2 请求(任何类型):这些库将负责转换您的
CONNECT
请求转换为正确的字节以通过网络发送。The format of the
CONNECT
method in HTTP/2 is specified in section 8.3.With the formatting you used above looks like:
As specified,
:scheme
and:path
must be omitted.The HTTP/2
CONNECT
method can also be used for bootstrapping other protocols (see for example WebSocket over HTTP/2), so that, additionally, the:protocol
pseudo-header may also be present.Remember however that this is only a textual representation of HTTP/2; the bytes that actually travel over the network are different since you must encode them using HPACK.
Unless you are actually writing an HTTP/2 implementation, it is better that you use existing libraries (available in virtually any programming language) to send HTTP/2 requests (of any kind): the libraries will take care of converting your
CONNECT
request into the proper bytes to send over the network.