I have a handler which works as it should to serve a download. This is the important code:
// Get size of file
FileInfo f = new FileInfo(Settings.ReleaseFileLocation + ActualFileName);
long FileSize = f.Length;
// Init (returns ID of tblDownloadLog record created with blank end date)
int DownloadRecordID = Constructor.VersionReleaseDownload.newReleaseDownload(ActualFileName);
context.Response.Clear();
context.Response.Buffer = false;
context.Response.ContentType = "application/octet-stream";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + OriginalFileName);
context.Response.AddHeader("Content-Length", FileSize.ToString());
context.Response.TransmitFile(Settings.ReleaseFileLocation + ActualFileName);
context.Response.Close();
// Complete download log, fills out the end date
Constructor.VersionReleaseDownload.completeReleaseDownload(DownloadRecordID);
The context.Response.Close();
ensures the completeReleaseDownload()
only runs when the download is complete which is very useful (re Only count a download once it's served)
Problem is, we're getting a lot of logs that come from the same IP address in about the same time spacing. After digging a bit deeper it appears they are users using Download Resumer software.
When I try to use a download resumer it seems to fail. My question is:
- How do I detect this is a partial request
- How can I serve the partial request
- How can I make it work with the above code so it a) Calls
https://www.scirra.com/downloads/releases/construct2-r68-setup_4.exe
on the first partial get and b) CallscompleteReleaseDownload
on the last partial get?