How does pausing and resuming downloads work?

999 views

How does pausing and resuming downloads work?

In: Technology

2 Answers

Anonymous 0 Comments

The file being downloaded is a simple (GET) request. You open the connection, and read the incoming data (bytes) until the connection closes. You also know the size of the response from the beginning, that’s how you have a percentage.

For resuming the download request, you just do a “range” request:

GET /download.zip HTTP/1.1 Host: example.com Range: bytes=0-1023
which skips the portion of the response you have already received.
Though only the size of the file, and the validity of the incoming bytes is verified. If the server doesn’t resume correctly or the response is not the exact same, you get a corrupted file. That’s why hashing is being used for serious downloads (Firmware Updates etc.).

Anonymous 0 Comments

While the other answer is correct, I’ll try and simplify it a bit more:

Normal download: Hey, pls gimme that file
Resumed download: I already have half the file, could I have the other have pls?