HTTP2中的RST_STREAM帧 [英] RST_STREAM frame in HTTP2

查看:373
本文介绍了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_STREAM帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆