I want to develop a download manager supporting segmented download. So, I am looking for a library supporting the same. Please give suggestions regarding the best library available on Linux platform that could serve the purpose.

有帮助吗?

解决方案

Any library that supports custom HTTP headers, such as libcurl, will work.

You need to spawn several threads. In each thread, set the Range field in you request header to specify which part of the file this thread needs to download.

And for libcurl specially, you can use the CURLOPT_RANGE option to do partial file download.

See the description form libcurl's documentation.

CURLOPT_RANGE

Pass a char * as parameter, which should contain the specified range you want. It should be in the format "X-Y", where X or Y may be left out. HTTP transfers also support several intervals, separated with commas as in "X-Y,N-M". Using this kind of multiple intervals will cause the HTTP server to send the response document in pieces (using standard MIME separation techniques). For RTSP, the formatting of a range should follow RFC 2326 Section 12.29. For RTSP, byte ranges are not permitted. Instead, ranges should be given in npt, utc, or smpte formats.

Pass a NULL to this option to disable the use of ranges.

Ranges work on HTTP, FTP, FILE (since 7.18.0), and RTSP (since 7.20.0) transfers only.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top