4.2. Content-Range

0 阅读1分钟

4.2. Content-Range

rfc 7233 4.2. Content-Range

Content-Range field 无效(invalid)的情况

   A Content-Range field value is invalid if it contains a
   byte-range-resp that has a last-byte-pos value less than its
   first-byte-pos value, or a complete-length value less than or equal
   to its last-byte-pos value.  The recipient of an invalid
   Content-Range MUST NOT attempt to recombine the received content with
   a stored representation.

说的就是当如下3种情况时Content-Range无效,这里用bytes-units的情况举例:

Content-Range: bytes 45-44/1234

Content-Range: bytes 45-44/44
Content-Range: bytes 45-44/43

当recipient判断出"invalid"时就不能执行recombine。

上述“判断”显然只是“recipient的本地判断”,recipient根据上述判得出的并不是最“精确”的结果,毕竟如果服务器可能会给一个通过上述判断结果为"valid",但实际“错误”的Content-Range,例如:

representation实际长度1000

//服务器返回
Content-Range: bytes 45-44/300

显然,服务器返回了一个错误的结果。