4.3. Combining Ranges

1 阅读2分钟

4.3. Combining Ranges

rfc 7233 4.3. Combining Ranges

合并的主体

  • InComplete responses to GET
  • partial responses to GET

合并的条件(UNDEFINED,gemini)

如果2个主体能被合并,他们需要满足:

  • URI match
  • Method match
  • Vary match
  • share the same strong validator

在rfc本小节原文中的 “matching” 指的就是2个主体上述4个条件都满足的

share same strong validator

A client that has received multiple partial responses to GET requests
   on a target resource MAY combine those responses into a larger
   continuous range if they share the same strong validator.

"same"目前理解为"完全一致";"strong validator分为etage和Last-Modified的情况.

etag强验证器:

Etag: "123"

Last-Modified强验证器(UNDEFINED):

Last-Modified作为request中的validator时可以对其进行强弱验证器的判断(rfc 7232 2.2.2. Comparison);然而combining时没法满足这个前提

合并header

“most recent response”理解(UNDEFINED,gemini)

representation在本地对应多个responses,其中的response可能被存到cache中(stored);这些responses中“most recent response”指的是:

  • 在包含Date header的responses中,Date最大的那个response
  • 如果都没有Date,则按本地时间最新收到的那个

1.most recent response is an incomplete 200 (OK) response

用这个response的header fields:

  • 作为combined response的header fields
  • 替换所有matching stored responses(??这里的matching指的是?)

2.most recent response is a 206 (Partial Content) response

如果本地至少有一个matching stored response(200),则:

  • 使用最新的那个response(200)的header fields作为combined response的header fields。

如果所有的matching stored responses都是206,则:

  • 用收到的response(206) header fields替换掉most recent response(206) header fields以后的结果作为combined response的header fields。(这里有点绕,实质就是:不同的都保留,相同的替换)
  • 上述操作除开"Content-Range"(根据这个Header的定义,替换掉没有意义,那实际该如何处理呢?)

合并body

  1. 如果能拼出一个完整的representation,则必须(MUST)将combined response 当作response(200)来处理

  2. 否则必须(MUST):

    A. 如果可以拼出representation开头连续的一段,则将其处理为不完整的200 response来处理

    B. 可以将多个连续片段封装成一个单独的206 Partial Content 响应,并使用 multipart/byteranges 格式

    C. 将每一段连续的字节块分别处理为独立的 206 Partial Content 响应,每一段都要带有自己的 Content-Range 头。

当进入分支2.时,可以选择B或者C;如果条件满足,也可以选择A

MAY/MUST

A client that has received multiple partial responses to GET requests
   on a target resource MAY combine those responses into a larger
   continuous range if they share the same strong validator.

注意,这里使用了关键字"MAY",本小节的后续内容里使用了"MUST"。表达的意思是:

  • combine操作是可选的("MAY");但是一旦选择实现,则必须按照后面规定的"MUST"来