3.1. Range

2 阅读2分钟

3.1. Range

rfc 7233 3.1. Range

server May 忽略或者拒绝Range header的情况

 A server that supports range requests MAY ignore or reject a Range
   header field that consists of more than two overlapping ranges, or a
   set of many small ranges that are not listed in ascending order,
   since both are indications of either a broken client or a deliberate
   denial-of-service attack (Section 6.1). 

server可以(MAY)忽略或者拒绝 Range Header 当:

  • more than two overlapping ranges
  • a set of many small ranges that are not listed in ascending order

注意,这里是忽略或者拒绝2种选择。

client不应该发送包含多个range当请求。

A client SHOULD NOT request
   multiple ranges that are inherently less efficient to process and
   transfer than a single range that encompasses the same data

Range Header只能被包含在GET请求中

The "Range" header field on a GET request modifies the method
   semantics to request transfer of only one or more subranges of the
   selected representation data, rather than the entire selected
   representation data

Range Header可以被包含在GET request中.

 A server MUST ignore a Range header field received with a request method other
   than GET.

server会忽略method不是GET的request中的Range Header。

evaluated Range header的唯一情况

   The Range header field is evaluated after evaluating the precondition
   header fields defined in [RFC7232], and only if the result in absence
   of the Range header field would be a 200 (OK) response.  In other
   words, Range is ignored when a conditional GET would result in a 304
   (Not Modified) response.
  • 节选中的request的method是GET。因为Range header只能和GET一起使用
  • is evaluated after evaluating the precondition header fields defined in [RFC7232], and only if the result in absence of the Range header field would be a 200 (OK) response.”这段定义了唯一evaluate Range Header的情况:如果把这个GET请求中的RangeHeader去掉以后,服务器应该返回一个200 response(这意味着,所有参与验证的precondition都通过)。那么服务器在原本的GET请求时,会在evaluating the precondition之后evaluate Range Header。
  • In other words, Range is ignored when a conditional GET would result in a 304 (Not Modified) response.”这是对“唯一情况”以外的的其中一种情况的举例。