HTTP2中的RST

编程入门 行业动态 更新时间:2024-10-22 02:48:27
本文介绍了HTTP2中的RST_STREAM帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我了解了http2 RST_STREAM中的新功能:

I read about new feature in http2 RST_STREAM :

HTTP/2添加了RST_STREAM框架,以允许客户端改变主意; 如果浏览器离开某个页面,或者用户取消了 下载,它可以避免必须打开新连接而不会浪费 所有带宽.

HTTP/2 adds the RST_STREAM frame to allow a client to change its mind; if the browser navigates away from a page, or the user cancels a download, it can avoid having to open a new connection without wasting all of that bandwidth.

该怎么办?浏览器该怎么办?代码是否有变化?

How can do this?How Browser can do this?Is there any change in code?

推荐答案

浏览器会发起一个请求,然后通过用户导航或取消来改变其主意.

The browser initiates a request and then changes its mind, either with the user navigating away or by cancelling.

在HTTP/1.1中,避免下载响应内容的唯一选择是关闭连接,因为客户端无法将放弃请求的意图传达给服务器.关闭连接是方法.

In HTTP/1.1, the only choice to avoid the download of the response content was to close the connection, since there is no way for the client to communicate this intention of aborting the request to the server. Closing the connection is the way.

在HTTP/2中,如果客户端要中止请求,它将发送RST_STREAM.当服务器收到RST_STREAM时,它将停止向客户端发送DATA帧,从而停止响应(或下载). 该连接仍可用于其他请求,与已中止的请求并发的请求/响应可能会继续进行.

In HTTP/2, if the client wants to abort the request, it sends a RST_STREAM. When the server receives a RST_STREAM, it will stop sending DATA frames to the client, thereby stopping the response (or the download). The connection is still usable for other requests, and requests/responses that were concurrent with the one that has been aborted may continue to progress.

通常,应用程序不需要执行任何操作,也不需要了解RST_STREAM,这全部由浏览器和服务器实现完成.

Typically, applications do not need to do anything and are not aware of RST_STREAM, it is all done by the browser and by the server implementation.

有可能在RST_STREAM从客户端传播到服务器时,请求的全部内容正在传输中,并将到达客户端,客户端将丢弃该请求. 但是,对于较大的响应内容,发送RST_STREAM可能有很大的机会在发送整个响应内容之前到达服务器,因此可以节省带宽.

It is possible that by the time the RST_STREAM travels from the client to the server, the whole content of the request is in transit and will arrive to the client, which will discard it. However, for large response contents, sending a RST_STREAM may have a good chance to arrive to the server before the whole response content is sent, and therefore will save bandwidth.

更多推荐

HTTP2中的RST

本文发布于:2023-11-01 20:12:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:RST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!