问题描述
如果不支持 Range
,则对带有标题字段 Range:bytes = 278528-
的GET请求的正确响应是什么?
What is the correct response to a GET request with the header field Range: bytes=278528-
if Range
is not supported?
读取HTTP标头定义( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html )我认为我至少应该设置: Accept-Ranges:none
,但它明确指出
Reading the HTTP header definitions (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) i think i should at least set: Accept-Ranges: none
, but it clearly states that
因此,如果客户请求范围,我应该:
So, if a client requests a range, should I:
- 从字节0开始答复整个文件吗?
- 回复一些状态错误?(400/406/416/501),请参见: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
推荐答案
您可能会忽略它,如规范所述.准确地说:
You may ignore it, as the spec says. To be precise:
- 如果支持,则返回状态码206 Partial Content,并包含适当的标头,例如Content-Range.
- 如果您不支持它,则会照常返回200 OK.
我还没有测试过,但是规格似乎很清楚.我已经看到了这项工作-如果服务器不支持Range标头,则使用wget或curl恢复中断的下载将可以从头开始正确重启.
I have not tested this, but the spec seems pretty clear. I have seen this work — using wget or curl to resume an interrupted download will properly restart from the beginning if the server does not support the Range header.
这篇关于HTTP:我应如何回应& quot; Range:bytes =& quot ;;不支持Range的时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!