如何通过http下载文件的某个字节 [英] How to download a certain byte of the file via http

查看:88
本文介绍了如何通过http下载文件的某个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过HTTP协议下载前125个字节和125个最后一个字节文件?

How to download first 125 bytes and 125 last byte file via HTTP protocol ?

推荐答案

我相信你想发送一个适当的范围标题。有关详细信息,请参阅 HTTP / 1.1规范。请注意,并非所有服务器都支持此功能,请注意。您可能需要传输整个文件,只是为了获得最后125个字节。当然,你可以通过请求整个事件获得前125个字节,然后在杀死连接之前只读取前125个字节。

I believe you want to send an appropriate Range header. See the HTTP/1.1 spec for more information. Be aware that not all servers will support this, mind you. You may need to transfer the whole file, just to get to the last 125 bytes. Of course, you can get just the first 125 bytes by requesing the whole thing, and then only reading the first 125 bytes before killing the connection.

理论上我相信你应该可以使用:

In theory I believe you should be able to use:

Range: 0-124,-125

请注意,如果完整响应小于250字节,这将给出有趣的结果。 。

Note that this will give interesting results if the full response would be less than 250 bytes...

Accept-Ranges: bytes
Range: bytes=-255

这篇关于如何通过http下载文件的某个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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