How does pausing and resuming downloads work?

1.03K 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.).

You are viewing 1 out of 2 answers, click here to view all answers.