RST_STREAM frame in HTTP2
Asked Answered
R

1

13

I read about new feature in http2 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 can a browser do this? Is there any change in code?

Rapallo answered 26/2, 2015 at 7:12 Comment(0)
M
25

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

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.

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.

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.

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.

Mccloud answered 1/3, 2015 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.