Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use Internet Download Manager (IDM) for downloading data, and I have noticed that in it's download progress window, it shows whether or not a download is pause-able (resume-able). Typically, file-sharing sites do not allow the transfer to be resumed if the connection is broken.

So the question is this: how does this work? Is it some config that's done on the sever? How does this differ from torrent downloads, where the download is always resume-able.

share|improve this question

2 Answers 2

up vote 9 down vote accepted

From a coding perspective, a download is just a just a byte array included in the HTTP response stream.

The HTTP 1.1 protocol (see page 30) includes a field in the Header called 'Range', which allows the request to specify the byte offset and length of the response requested.

So in essence you can say, "give me the HTTP object at this URL, but I only want the 1024th - 4096th bytes of it". The client browser then appends the byte stream to the portion of the file already downloaded. The client can tell where it needs to resume simply by checking the length of the file already downloaded, and increment it to determine the required offset.

As to how your download manager can tell, it sends an HTTP "HEAD" request. If the response code is 206 (partial content), then the http stream supports resumption.

share|improve this answer
    
FTP is also a commonly used protocol for transferring files. It used to be the primary means, though now HTTP is probably more common. –  ChrisInEdmonton Sep 6 '13 at 18:22
    
FTP uses essentially the same construct, though I'd have to look up the specifics before I'd attempt to implement code that uses it. –  Frank Thomas Sep 6 '13 at 18:33

This could be handled using a Persistent cookie, not to be confused with a session cookie or you can use [Viewstate] if the site is built on ASP.NET, however this is not a good practice. Frank Thomas has the best answer.

share|improve this answer
1  
I am not sure the reason this answer was downvoted so I upvoted it. –  Ramhound Sep 6 '13 at 16:39
    
Please elucidate. it doesn't make sense that either cookies or viewstate would help the server serve you only the undownloaded remains of the file. are you saying that the cookie or viewstate is constantly updated for every byte downloaded from every file the server serves to you in a session? –  Frank Thomas Sep 6 '13 at 16:44
    
@FrankThomas, I just confirmed some facts with our senior developer and he said you 'could' use a Persistent cookie or viewstate to store the byte array's index information used in tracking & resuming the download through a browser based downloader, however it wasn't a good practice. Typically, for large resumable files, such as an MS product, you would download a download Manager application and it would work just as you said. I have upvoted your answer. –  Josh Campbell Sep 6 '13 at 17:36
    
This answer appears meaningless. It's not a problem of determining how much of the file has been downloaded; the client knows this already. You can communicate that back to the server using a cookie, but there are far better approaches. Headers, GET or POST params, etc. The question is asking how the file transfer is resumed, not how to pass information to a server. –  ChrisInEdmonton Sep 6 '13 at 18:22
    
The OP asked how it works and I pointed him in the direction of Cookies so that he could do further research. There are a dozen different ways a developer could make a resumable downloader. I would have done it using cookies on the client to track the download status via a start-stop index and used C# on the backend to calculate how much was downloaded (from index X to index Y) and then resumed from Y. A desktop download manager does the exact same thing, only it stores its information in a text file or database. This isn't stackoverflow, I'm not writing source code. –  Josh Campbell Sep 6 '13 at 18:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.