获取范围 header returns 部分内容和后续请求 returns 无数据的文件内容
Getting file contents with Range header returns Partial Content and subsequent request returns no data
我们在使用 OneDrive API 获取文件内容时遇到 non-understandable 问题。
当我们请求范围为 header:
的文件内容时
GET /blahblah/foobar.docx HTTP/1.1
Host: qw122q-ch3301.files.1drv.com
Accept: */*
Accept-Encoding: deflate, gzip
Range: bytes=0-77270
OneDrive returns:
HTTP/1.1 206 Partial Content
Cache-Control: no-cache
Content-Length: 18325
我们使用 Web 界面检查 OneDrive 服务器上的文件大小是否正确。通常 OneDrive returns 完整请求的内容,但从上周开始他们 returns 部分内容。但是,如果我们可以通过另一个 API 调用获得剩余部分,那也没关系。
但是当我们发送另一个范围为 header:
的请求时
Range: bytes=18325-77270
OneDrive returns 无数据:
HTTP/1.1 206 Partial Content
Control: no-cache
Content-Length: 0
有人遇到过这个问题吗?我无法从 OneDrive 开发人员文档中找到有关此问题的任何线索。请阐明这一点..
其实我有一个理论,所以我要试一下答案。实际上有两个不同的问题导致了这种令人困惑的行为,所以我将分别解决每个问题。
报告的文件大小与内容大小不匹配
This is an unfortunate quirk of the system that is being tracked with this GitHub issue. Ryan explains in more detail here.
Word 文档的范围下载无法正确处理无法满足的范围
When a range outside of the actual file size is requested we should be failing with a 416 Requested Range Not Satisfiable
like we do for "normal" files. But that's obviously not working. You can see in the Content-Range
of the result there's something screwy going on:
FileSize: 15 bytes
Range Requested: bytes=15-
Content-Range Response: bytes=15-14/15
The value of the Content-Range
obviously makes no sense.
这两个问题共同导致了您所看到的奇怪行为。我们即将解决第一个问题,而第二个问题(至少对我而言)是未知的,所以我打开了一个 new GitHub issue 来跟踪它。
我们在使用 OneDrive API 获取文件内容时遇到 non-understandable 问题。
当我们请求范围为 header:
的文件内容时GET /blahblah/foobar.docx HTTP/1.1
Host: qw122q-ch3301.files.1drv.com
Accept: */*
Accept-Encoding: deflate, gzip
Range: bytes=0-77270
OneDrive returns:
HTTP/1.1 206 Partial Content
Cache-Control: no-cache
Content-Length: 18325
我们使用 Web 界面检查 OneDrive 服务器上的文件大小是否正确。通常 OneDrive returns 完整请求的内容,但从上周开始他们 returns 部分内容。但是,如果我们可以通过另一个 API 调用获得剩余部分,那也没关系。
但是当我们发送另一个范围为 header:
的请求时Range: bytes=18325-77270
OneDrive returns 无数据:
HTTP/1.1 206 Partial Content
Control: no-cache
Content-Length: 0
有人遇到过这个问题吗?我无法从 OneDrive 开发人员文档中找到有关此问题的任何线索。请阐明这一点..
其实我有一个理论,所以我要试一下答案。实际上有两个不同的问题导致了这种令人困惑的行为,所以我将分别解决每个问题。
报告的文件大小与内容大小不匹配
This is an unfortunate quirk of the system that is being tracked with this GitHub issue. Ryan explains in more detail here.
Word 文档的范围下载无法正确处理无法满足的范围
When a range outside of the actual file size is requested we should be failing with a
416 Requested Range Not Satisfiable
like we do for "normal" files. But that's obviously not working. You can see in theContent-Range
of the result there's something screwy going on:
FileSize: 15 bytes
Range Requested: bytes=15-
Content-Range Response: bytes=15-14/15
The value of the
Content-Range
obviously makes no sense.
这两个问题共同导致了您所看到的奇怪行为。我们即将解决第一个问题,而第二个问题(至少对我而言)是未知的,所以我打开了一个 new GitHub issue 来跟踪它。