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:
+ +
If response’s header list does not contain `Content-Range
`, then return failure.
+
+
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.
+
+
If parsing contentRangeValue per single byte content-range fails, then return failure. + +
Let firstBytePos be the portion of contentRangeValue named + first-byte-pos when parsed as single byte content-range, parsed as an integer. + +
Let lastBytePos be the portion of contentRangeValue named + last-byte-pos when parsed as single byte content-range, parsed as an integer. + +
Let completeLength be the portion of contentRangeValue named + complete-length when parsed as single byte content-range. + +
If completeLength is "*
", then set completeLength to null, otherwise
+ set completeLength to completeLength parsed as an integer.
+
+
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:
+ +Assert: partialResponse's status is `206`. + +
Let responseFirstBytePos, responseLastBytePos, and responseCompleteLength be the + result of extracting content-range values from partialResponse. If this fails, then return invalid. + +
If responseFirstBytePos does not equal expectedRangeStart, then return invalid. + +
If previousResponse is not null, then: + +
For headerName of « `ETag
`, `Last-Modified
` »:
+
+
If previousResponse's status is 206, then: + +
Let previousResponseFirstBytePos, previousResponseLastBytePos, + and previousResponseCompleteLength be the result of extracting content-range values + from previousResponse. If this fails, then return invalid. + +
If previousResponseCompleteLength is not null, and + responseCompleteLength does not equal previousResponseCompleteLength, then return invalid. +
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. + +
+ 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 ++