HttpWebRequest or WebRequest - Resume Download ASP.NET

后端 未结 2 1376
一生所求
一生所求 2020-12-07 21:41

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

相关标签:
2条回答
  • 2020-12-07 21:56

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

    0 讨论(0)
  • 2020-12-07 22:20

    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 function.

    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.

    0 讨论(0)
提交回复
热议问题