问题
I want to write a C++ program to download files with HTTP. For the sake of learning I would like to implement multipart downloading in my program the way DownThemAll! does. It is not possible to do lseek on a linux socket. I suppose it would be some HTTP option that we would need to specify, telling where to start downloading the file from. Thus we could have multiple connections open to the server. Is it right? What are the HTTP headers for doing so?
回答1:
I suggest you take a look at section 14.35.1 Byte Ranges of the HTTP spec:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
回答2:
You need the Range HTTP header.
回答3:
There is a library based on C++ and ASIO called Urdl.
ASIO link: http://asio.sourceforge.net
Urdl link: http://think-async.com/Urdl/doc/html/index.html
来源:https://stackoverflow.com/questions/1390471/how-to-write-a-multipart-download-c-program