【发布时间】:2014-10-08 08:57:00
【问题描述】:
由于我正在通过 XHTTPRequest(由 Google Closure XhrIo 提供)下载一个巨大的 JSON 文件 (> 10 MB),我想使用字节范围请求仅下载部分数据:
3.12 Range Units
HTTP/1.1 allows a client to request that only part (a range of) the response entity be included within the response. HTTP/1.1 uses range units in the Range (section 14.35) and Content-Range (section 14.16) header fields. An entity can be broken down into subranges according to various structural units.
range-unit = bytes-unit | other-range-unit
bytes-unit = "bytes"
other-range-unit = token
The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1 implementations MAY ignore ranges specified using other units.
因为唯一定义的range-unit 是bytes 我想知道如何以字符方式访问请求的文件以构建字符串。这可能是个问题,因为它依赖于字符代码。
如何计算所请求文件的字符集的字节范围以按字符方式访问文件?
如何累积接收到的chunk的数据?
我怎样才能为这个请求的数据创建一个字符串甚至 JSON 表示?
【问题讨论】:
标签: javascript json http byte