HTTP2中应该是什么连接消息标头?

发布于 2025-01-19 00:14:00 字数 828 浏览 2 评论 0原文

我发现获取消息头看起来像:

: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠北森屋 2025-01-26 00:14:00

HTTP/2 中的 CONNECT 方法的格式在 第 8.3 节

上面使用的格式如下所示:

:method: CONNECT
:authority: proxy.net:8080

根据指定,: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:

:method: CONNECT
:authority: proxy.net:8080

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文