diff --git a/fetch.bs b/fetch.bs index b3d273342..aaa053f20 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3339,7 +3339,6 @@ and a response response, is to run these steps:
  • If response's status is 206 and validate a partial response given 0 and response returns invalid, then return false. -

  • Let bytes be the result of running obtain a copy of the first 1024 bytes of response given response. @@ -3387,6 +3386,81 @@ and a response response, is to run these steps:


    +
    +

    To extract content-range values, given an response response +run these steps:

    + +

      +
    1. If response’s header list does not contain `Content-Range`, then return failure. + +

    2. Let contentRangeValue be the value of the first header whose name is a + byte-case-insensitive match for `Content-Range` in response’s header list. + +

    3. If parsing contentRangeValue per single byte content-range fails, then return failure. + +

    4. Let firstBytePos be the portion of contentRangeValue named + first-byte-pos when parsed as single byte content-range, parsed as an integer. + +

    5. Let lastBytePos be the portion of contentRangeValue named + last-byte-pos when parsed as single byte content-range, parsed as an integer. + +

    6. Let completeLength be the portion of contentRangeValue named + complete-length when parsed as single byte content-range. + +

    7. If completeLength is "*", then set completeLength to null, otherwise + set completeLength to completeLength parsed as an integer. + +

    8. Return firstBytePos, lastBytePos, and completeLength. +

    + +

    Parsing as an integer infra/189 +

    + +
    + +
    +

    To validate a partial response, given an integer expectedRangeStart , a +response partialResponse, and an optional response previousResponse (default null), +run these steps:

    + +
      +
    1. Assert: partialResponse's status is `206`. + +

    2. Let responseFirstBytePos, responseLastBytePos, and responseCompleteLength be the + result of extracting content-range values from partialResponse. If this fails, then return invalid. + +

    3. If responseFirstBytePos does not equal expectedRangeStart, then return invalid. + +

    4. If previousResponse is not null, then: + +

        +
      1. For headerName of « `ETag`, `Last-Modified` »: + +

          +
        1. If previousResponse's header list contains headerName + and the combined value of headerName + in previousResponse's header list does not equal the + combined value of headerName in partialResponse's + header list, then return invalid. +
        + +
      2. If previousResponse's status is 206, then: + +

          +
        1. Let previousResponseFirstBytePos, previousResponseLastBytePos, + and previousResponseCompleteLength be the result of extracting content-range values + from previousResponse. If this fails, then return invalid. + +

        2. If previousResponseCompleteLength is not null, and + responseCompleteLength does not equal previousResponseCompleteLength, then return invalid. +

        +
      +
    5. Return valid. +
    +
    + +
    +

    To obtain a copy of the first 1024 bytes of response, given a response response, run these steps: @@ -3808,6 +3882,45 @@ response headers, the value `*` coun requests without credentials. For such requests there is no way to solely match a header name or method that is `*`. +

    ABNF for a single byte content-range: + +

    
    +"bytes=" first-byte-pos "-" last-byte-pos "/" complete-length
    +first-byte-pos = 1*DIGIT
    +last-byte-pos  = 1*DIGIT
    +complete-length = ( 1*DIGIT / "*" )
    +
    + +

    This is a subset of what RFC 7233 allows. + +

    + + The above as a railroad diagram: + +
    +  T: "bytes="
    +  Stack:
    +    Sequence:
    +      Comment: first-byte-pos
    +      OneOrMore:
    +        N: digit
    +      Comment: /first-byte-pos
    +      N: "/"
    +    Sequence:
    +      Comment: last-byte-pos
    +      OneOrMore:
    +        N: digit
    +      Comment: /last-byte-pos
    +      N: "/"
    +    Sequence:
    +      Comment: complete-length
    +      Choice:
    +        N: "*"
    +        OneOrMore:
    +          N: digit
    +      Comment: /complete-length
    +  
    +

    CORS protocol and credentials