HTTP:我应如何回应& quot; Range:bytes =& quot ;;不支持Range的时候? [英] HTTP: How should I respond to "Range: bytes=" when Range is unsupported?

查看:58
本文介绍了HTTP:我应如何回应& quot; Range:bytes =& quot ;;不支持Range的时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果不支持 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

客户端可能会生成字节范围的请求,而不会收到所涉及资源的此标头.

Clients MAY generate byte-range requests without having received this header for the resource involved.

因此,如果客户请求范围,我应该:

So, if a client requests a range, should I:

推荐答案

您可能会忽略它,如规范所述.准确地说:

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的时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆