最后一个字节的 HTTP 范围请求

标签 http protocols http-range

我是新手,I've been studying字节服务的 Range 请求。我发现服务器必须发送一个字节范围,如下所示

Content-Range: bytes 734-1233/1234

最后一个字节范围。但是,当请求本身只剩下最后一个字节时,浏览器如何获取文件的最后一个字节呢?

最佳答案

当前标准为RFC 7233 。来自 2.1 Byte Ranges :

The first-byte-pos value in a byte-range-spec gives the byte-offset
of the first byte in a range.  The last-byte-pos value gives the
byte-offset of the last byte in the range; that is, the byte
positions specified are inclusive.  Byte offsets start at zero.

将此应用于 4.2 Content-Range 中的示例:

The following are examples of Content-Range values in which the
selected representation contains a total of 1234 bytes:

o  The first 500 bytes:

     Content-Range: bytes 0-499/1234

由于范围是从零开始的,因此 0 是第一个字节,499 是第 500 个字节。因此,1233 是 1234 字节文档的最后一个字节。

关于最后一个字节的 HTTP 范围请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39697023/

相关文章:

http - 为什么不使用其余的 HTTP 动词?

可以重新声明 Swift 内置协议(protocol)吗?为什么?

javascript - 如何获取 Meteor 的 HTTP.call(或 get)方法来修改 HTTP 请求 header ?

python - 试图将文件下载缓冲区拆分为单独的线程

node.js - 使用 node-soap 发送 cookie

ruby-on-rails - 带有 JQTouch 登录问题的 iPhone 上的 Rails

serial-port - DTR/DSR 和 RTS/CTS 流量控制有什么区别?

在其他命名空间中找不到记录类型的 Clojure 协议(protocol)实现

URL 的 Java Android 重定向不起作用