Javascript XMLHTTPRequest字节范围请求
由于我正在通过Google Closure提供的XHTPrequest下载一个大于10 MB的巨大JSON文件,因此我希望使用字节范围请求仅下载部分数据:Javascript XMLHTTPRequest字节范围请求,javascript,json,http,byte,Javascript,Json,Http,Byte,由于我正在通过Google Closure提供的XHTPrequest下载一个大于10 MB的巨大JSON文件,因此我希望使用字节范围请求仅下载部分数据: 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 Rang
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.
因为唯一定义的范围单位是字节,所以我想知道如何以字符方式访问请求的文件来构建字符串。这可能是一个问题,因为它依赖于字符代码
如何计算与请求文件的字符集相关的字节范围,以便以字符方式访问文件
如何累积接收到的数据块的数据
如何创建此请求数据的字符串或甚至JSON表示形式?1您不能,除非它是一种具有固定八位字节/字符比率的字符编码,这对于JSON来说不太可能,因为在大多数情况下它将是UTF-8 2以及字节数组:- 3您可以尝试跳到根据使用的编码有效的第一个字节序列。应该有必要的细节