We are providing downloads of our application setups through an ASHX handler in ASP.NET.
A customer told us he uses some third party download manager application and that our way of providing the files currently does not support the "resume" feature of his download manager application.
My questions are:
What are the basic ideas behind resuming a download? Is there a certain HTTP GET request that tells me the offset to start at?
Resuming a download usually works through the HTTP
Range
header. For example, if a client wants only the second kilobyte of a file, it might send the headerRange: bytes=1024-2048
.You can see page 139 of the RFC for HTTP/1.1 for more information.
Thanks icktoofay for getting me started, here's a complete example to save other developers some time:
Disk Example
Database Example
Helper Methods
What this demonstrates is a way of reading part of the file from either the disk or database and outputting as response rather than loading the entire file into memory, which wastes resources if the download is paused or resumed half way through.
Edit: added etag to enable resumable downloads in IE9, thanks to EricLaw for his help in getting it to work correctly in IE9.