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.
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
Response
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
Response
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.