Reputation: 61775
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:
https://www.scirra.com/downloads/releases/construct2-r68-setup_4.exe
on the first partial get and b) Calls completeReleaseDownload
on the last partial get?Upvotes: 2
Views: 1021
Reputation: 15140
This is achieved in Mime with an E-Tag, check out: http://www.devx.com/dotnet/Article/22533/1954
When you capture some packets sent using DownloadResumer
, you will probably find the Range
tag being specified.
Range: bytes=500-1000
This allows you to check if this is a partial request and if so, take action like:
bool isFirstRequest = RangeStart == 0;
bool isLastRequest = RangeEnd == file.TotalBytes - 1;//(Ranges use Zero-Based Indices)
Upvotes: 2