HttpWebRequest的WebRequest的还是 - 简历下载ASP.NET [英] HttpWebRequest or WebRequest - Resume Download ASP.NET

查看:146
本文介绍了HttpWebRequest的WebRequest的还是 - 简历下载ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以知道,如果一个服务器支持恢复下载functionallity,如果支持,我怎么发送到恢复请求?

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?

我一直在寻找一个解决方案,我的ASP.NET页面可以从服务器做一个下载到矿山,类似 rapidleech 今天呢,但我想,以检查是否在那里我请求下载服务器支持的简历functionallity。

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.

推荐答案

恢复文件是通过指定的文件的字节范围做了你想使用下载范围 HTTP标头。这可以在.NET做的<一个href=\"http://msdn.microsoft.com/en-us/library/4ds43y3w.aspx\"><$c$c>HttpWebRequest.AddRange功能。

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.

例如:

request.AddRange(1000); 

将告诉服务器开始在文件的第1000个字节的发送。

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

如果服务器支持Range头,它会发送206(部分内容)的HTTP状态的内容,而不是正常的200(OK)。请参阅 HTTP规范

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.

要检查服务器是否支持恢复尝试下载之前,更改的HttpWebRequest 方法HEAD 。服务器会返回206(部分内容),如果它支持恢复和200(OK),如果它没有。

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.

这篇关于HttpWebRequest的WebRequest的还是 - 简历下载ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆