HTTP 状态代码 206:什么时候应该使用它?

2023-12-04

The 206 状态码(w3.org) 表示响应请求的部分结果Range header.

所以“显然”如果请求的文件是例如1024 字节长,并且Range标头是bytes=0-512然后是状态码206 Partial Content应该被退回。 (假设服务器能够返回内容)

但如果Range is bytes=0-2000?
Should 200 OK or 206 Partial Content被退回?
在我看来,规范中没有明确定义这一点——或者也许我没有读到正确的地方?

我为什么关心?我问是因为清漆缓存似乎总是会回来206 Partial Content,而Facebook 开放图调试器似乎期待200 OK. [1] [2]

Example:向 Varnish 发出 GET 请求
(我收到了完整的文件,但206 Partial Content被返回)

> curl --dump-header - -H 'Range: bytes=0-7000' https://www.varnish-cache.org/sites/all/themes/varnish_d7/logo.png
HTTP/1.1 206 Partial Content
Server: nginx/1.1.19
Date: Mon, 14 Apr 2014 22:43:31 GMT
Content-Type: image/png
Content-Length: 2884
Connection: keep-alive
Last-Modified: Thu, 15 Dec 2011 12:30:46 GMT
Accept-Ranges: bytes
X-Varnish: 1979866667
Age: 0
Via: 1.1 varnish
Content-Range: bytes 0-2883/2884

进一步w3参考:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35


没关系。两个回复都有效。

(另请注意,当前规范现在是http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p5-range-26.html,即将作为 RFC 发布)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HTTP 状态代码 206:什么时候应该使用它? 的相关文章

随机推荐