HTTP车身流期间/之后如何发送HTTP标头?有规格的工作吗?

发布于 2025-01-28 13:08:00 字数 485 浏览 3 评论 0 原文

如今,在将一位HTTP主体发送到浏览器之前,HTTP标头都需要发送。

这对于诸如React 18流的新技术尤其有问题,其中某些标头(例如缓存标头和 103早期提示)只能在HTTP流的末尾确定。理想情况下,这些后期标头将在结束流之前将其发送到浏览器。

Spec工作组或浏览器供应商是否有能力在HTTP主体期间/之后发送标头?

进行研究之后,似乎没有关于此事的规格工作,但是我想知道是否有浏览器供应商正在为此工作吗? (一些浏览器的人在stackoverflow上处于活动状态。)

上下文:我是 react-streaming

Today, HTTP headers all need to be sent before a single bit of HTTP body is sent to the browser.

This is especially problematic with new technologies such as React 18 Streaming where certain headers, such as caching headers and 103 Early Hints, can be determined with certainty only at the end of the HTTP stream. Ideally these late headers would be sent to the browser just before ending the stream.

Are there efforts from spec working groups or browser vendors to enable headers to be sent during/after the HTTP body?

After doing research, it seems that there is no spec work about this, but I wonder if there is a browser vendor working on this? (Some browser folks are active here on StackOverflow.)

Context: I'm the author of vite-plugin-ssr and react-streaming.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

奈何桥上唱咆哮 2025-02-04 13:08:00

有针对截面编码的拖车字段的规范(http 1.1,)。

HTTP2 SPEC(不支持块编码)直接允许遵循包含http车身的数据框架 https://datatracker.ietf.org/doc/html/rfc7540#section-8.1

由于大多数HTTP库都试图抽象基础协议中的差异,因此库支持可能会有所不同。在JavaScript中,您将有兴趣在跨浏览器标准fetch API中启用尾随标题。 MDN文档建议,支持预告片字段响应对象: https://developer.mozilla.org/en-us/docs/web/api/response

There is a specification for Trailer fields for use with Chunked Encoding (Http 1.1, https://httpwg.org/specs/rfc7230.html#header.trailer).

The HTTP2 spec (which does not support Chunked Encoding) directly allows for a headers frame following the Data frames that contain the http body https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.

Library support may vary as most http libraries attempt to abstract away the differences in the underlying protocols. In Javascript you will be interested in enabling trailing headers in the cross-browser standard fetch API. The MDN docs suggest that support is coming with reference to a trailers field on the Response object: https://developer.mozilla.org/en-US/docs/Web/API/Response.

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