HTTP:我应该如何回应“Range:bytes =”当Range不受支持时? [英] HTTP: How should I respond to "Range: bytes=" when Range is unsupported?

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

问题描述

如果范围,则标头字段的范围:bytes = 278528 - 不支持?

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:

  • Reply with the whole file from byte 0?
  • Reply with some status error? (400/406/416/501) see: 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:我应该如何回应“Range:bytes =”当Range不受支持时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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