Resume aborted download?
c++, http, winapi, windows, wininet
Solution
HTTP resume is somewhat a misnomer as the connection is usually terminated when the download is "paused" and then when it is resumed, a new request is made.
The new request then contains the range specification, so the server only sends a portion of the whole requested file.
Usually you would first fire a HEAD request to get the whole filesize.
Request
HEAD /big_file.zip HTTP/1.1
Host: www.example.com
Response
HTTP/1.0 200 OK
Accept-Ranges: bytes
Content-Length: 2000000
Content-Type: application/zip
Then you can send a request like this to only download bytes from 1,000,000 to 2,000,000 (if your first download stopped at 1,000,000 bytes):
Request
GET /big_file.zip HTTP/1.1
Host: example.com
Range: bytes=1000000,2000000
Response
HTTP/1.0 206 Partial Content
Accept-Ranges: bytes
Content-Length: 1000000
Content-Range: bytes 1000000-2000000/2000000
Content-Type: image/jpeg
...
That would be the general principle. You can implement it in C++ using cUrl, `boost::asio`, Windows sockets, ... There are many different ways and many good tutorials.
Problem
I have few PC's that run on slow Internet connection network + they use VPNs so the connection becomes really slow. I have my own app that must download updates from external server via HTTP, but if the update is around few MBs it doesn't get downloaded. So what i am asking is how to implement download method so i can resume the download if the connection is aborted. I code on Windows, C++, it would be good if i can achieve this using WinAPI. I think internet explorer has this feature, so it must be implemented with WININET.