如何不连续地从服务器下载数据? [英] How to download the data from the server discontinuously?

查看:16
本文介绍了如何不连续地从服务器下载数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从服务器下载一个大数据,因为数据太大,我不能一次下载,你有什么想法吗?非常感谢.

i need to download a big data from the server,because the data is so big,i am not able to download it at a time,do you have any idea?Thanks you very much.

推荐答案

如果服务器支持,您可以使用 HTTP 字节范围来请求文件的特定部分.

If the server supports it, you can use HTTP byte ranges to request specific parts of the file.

此页面描述了 HTTP 字节范围请求:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1

This page describes HTTP byte range requests: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1

以下代码创建一个请求,要求跳过前 100 个字节,但返回文件的其余部分:

The following code creates a request which will ask to skip the first 100 bytes, but return the rest of the file:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://example.com/somelargefile");
request.Headers.Add("Range", "bytes=100-");

这篇关于如何不连续地从服务器下载数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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