Nginx supports user multithreading downloads and breakpoint continuation

Source: Internet
Author: User

The range protocol is defined in the RFC2616 specification, which gives a rule that allows the client to download only a portion of the full file in a single request, thus enabling the client to download a file while the threads are open, each of which downloads only a portion of the file, which is finally combined into a complete file. Range also supports continuation of breakpoints, which allows the server to send the contents of a file from a breakpoint as long as the client records the portion of the file offset that has been downloaded.
The Nginx support for the range protocol is very good because the range protocol mainly adds some HTTP header processing processes and the offset processing when sending files. Nginx designed the HTTP filtering module, each request can be processed by many HTTP filtering modules, and the Http_range_header_filter module is used to process the HTTP request header range, which resolves the range header in the client request. Finally, the Ngx_http_range_body_filter_module module is called when the HTTP response inclusion is sent, and the module modifies the File_pos and file_last members of the ngx_buf_t buffer to the file according to the range protocol To send only a portion of a file to the client in this implementation.
In fact, the support range protocol for us is very simple, only to be set before sending the NGX_HTTP_REQUEST_T member Allow_ranges variable is 1, then will be completed by the HTTP framework. eg
R->allow_ranges = 1;
In this way, we support multithreaded downloads and breakpoint continuation.

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.