The principle of resumable transmission-http1.1 protocol

Reference article- analysis of the principle of resumable transmission

The principle of resumable transfer

Http principle of HTTP:
is http request on the defined plurality of associated HTTP HTTP header Rangeand Content-Rangefields (Range and Content-Range is HTTP / 1.1 in the new HTTP header field which is used from the server. Part of the content of a large file is obtained in, which greatly improves the operating efficiency of HTTP, and is very suitable for downloading software for multi-threaded downloading and resumable downloading.)

The HTTP1.1 protocol began to support access to part of the content of the file, which provides technical support for parallel download and resumable upload. It is achieved through two parameters in the Header, the client request corresponds to the Range, and the server responds to the Content-Range.

However, in actual scenarios, it may happen that when the terminal initiates a resuming request, the content of the file corresponding to the URL has changed on the server side, and the resuming data must be wrong at this time. How to solve? At this point, there needs to be a way to identify the uniqueness of the file. There are also corresponding definitions in RFC2616, such as implementing Last-Modified to identify the last modification time of the file, so that it can be judged whether the resuming file has been modified. At the same time, RFC2616 also defines an ETag header, which can be used to place the unique identifier of the file, such as the MD5 value of the file.

When the terminal initiates a resuming request, it should declare the if-Match or If-Modified-Since field in the HTTP header to help the server identify file changes.

In addition, there is an if-range header defined in RFC2616 at the same time. If the terminal uses the if-Range in the resume transmission. The content in if-Range can be the first received ETag header or the last modification time in Last-Modfied. When the server receives the resuming request, it will verify the content in the If-Range. If the verification is consistent, it will return a 206 resuming response. If it is inconsistent, the server will return a 200 response. The content of the response is all of the new file. data.

Guess you like

Origin blog.csdn.net/qq_38469784/article/details/112585783