views:

1259

answers:

3

I would like to know if there is a way to know if a server supports resume download functionallity and if supported, how do I send a request to resume?

I was looking for a solution where my ASP.NET page can do a download from a server to mine, something like "rapidleech" does today, but I would like to check if the server where i'm requesting the download supports resume functionallity.

A: 

I believe you'll find your answer here:

http://forums.asp.net/t/1218116.aspx

John Rasch
-1 for guessing and for posting a link that might not or does not have an answer.
acidzombie24
@acidzombie24 - please enlighten me as to where I "guessed" the answer. The answer I linked to is essentially the exact same procedure used for the accepted answer here except more complete, I just didn't feel like summarizing it. Did you even read the code sample provided in the link?
John Rasch
+4  A: 

Resuming files is done by specifying the byte range of the file you would like to download using the Range HTTP header. This can be done in .NET with the HttpWebRequest.AddRange fucntion.

For example:

request.AddRange(1000);

Will tell the server to begin sending at the 1000th byte of the file.

If the server supports the Range header, it will send the content with an HTTP status of 206 (Partial Content) instead of the normal 200 (OK). See the HTTP Spec.

To check if the server supports resuming before attempting the download, change the HttpWebRequest's Method "HEAD". The server will return 206 (Partial Content) if it supports resuming, and 200 (OK) if it does not.

Adam Hughes
so, if server doesnt suport, will it send a normal 200?
Cleiton
Yes. According to the HTTP spec, the server will send a normal 200 with all of the content if it does not support ranges.You can also check what the server specified in the "Accept-Ranges" header on your initial download attempt to see if it supports sending ranges (should be "bytes" or "none"). This header is not required, so if there is not "Accept-Ranges" header it may accept ranges.
Adam Hughes
@Adam, many thanks!
Cleiton
+2  A: 

You can find more information on Range specific requests by Scott Mitchell here

Neil
@Neil, thanks for this great link
Cleiton