Principle of HTTP resumable upload

Source: Internet
Author: User
Tags microsoft iis
In fact, the principle of resumable upload is very simple, that is, the HTTP request is different from the general download.

For example, when a browser requests a file on the server, the request is as follows:
Assume that the server domain name is wwww.scu.edu.cn, and the file name is down.zip.
GET/down.zip HTTP/1.1
Accept: image/GIF, image/X-xbitmap, image/JPEG, image/pjpeg, application/vnd. MS-
Excel, application/MSWord, application/vnd. MS-PowerPoint ,*/*
Accept-language: ZH-CN
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Connection: keep-alive

After receiving the request, the server searches for the requested file, extracts the file information, and then returns it to the browser. The returned information is as follows:

200
Content-Length = 106786028
Accept-ranges = bytes
Date = Mon, 30 Apr 2001 12:56:11 GMT
Etag = W/"02ca57e173c11: 95b"
Content-Type = application/octet-stream
Server = Microsoft-Microsoft IIS/5.0
Last-modified = Mon, 30 Apr 2001 12:56:11 GMT

 

The so-called resumable upload means that the download starts from where the object has been downloaded. Therefore, it is sent
Add one more message to the Web server-where to start.
The following is a self-compiled "Browser" to transmit the request information to the Web server, starting from 2000070 bytes.
GET/down.zip HTTP/1.0
User-Agent: netfox
Value Range: bytes = 2000070-
Accept: text/html, image/GIF, image/JPEG, *; q =. 2, */*; q =. 2

Take a closer look and you will find that there is an additional row range: bytes = 2000070-
In this line, the file down.zip is uploaded starting from 2000070 bytes, and the previous bytes are not required.
After receiving the request, the server returns the following information:
206
Content-Length = 106786028
Content-range = bytes 2000070-106786027/106786028
Date = Mon, 30 Apr 2001 12:55:20 GMT
Etag = W/"02ca57e173c11: 95b"
Content-Type = application/octet-stream
Server = Microsoft-Microsoft IIS/5.0
Last-modified = Mon, 30 Apr 2001 12:55:20 GMT

Compared with the information returned by the preceding server, a new row is added:
Content-range = bytes 2000070-106786027/106786028
The Returned Code is also changed to 206, instead of 200.

With the above principles, you can program resumable data transfer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.