@@ -3344,7 +3344,6 @@ and a <a for=/>response</a> <var>response</var>, is to run these steps:
3344
3344
<li><p> If <var> response</var> 's <a for=response>status</a> is 206 and
3345
3345
<a>validate a partial response</a> given 0 and <var> response</var> returns invalid, then return
3346
3346
false.
3347
- <!-- TODO Integrate https://wicg.github.io/background-fetch/#validate-a-partial-response into Fetch -->
3348
3347
3349
3348
<li><p> Let <var> bytes</var> be the result of running
3350
3349
<a>obtain a copy of the first 1024 bytes of response</a> given <var> response</var> .
@@ -3392,6 +3391,81 @@ and a <a for=/>response</a> <var>response</var>, is to run these steps:
3392
3391
3393
3392
<hr>
3394
3393
3394
+ <div algorithm>
3395
+ <p> To <dfn>extract content-range values</dfn> , given a <a for=/>response</a> <var> response</var>
3396
+ run these steps:<p>
3397
+
3398
+ <ol>
3399
+ <li><p> If <var> response</var> ’s <a for=response>header list</a> <a for="header list">does not contain</a> `<code> Content-Range</code> `, then return failure.
3400
+
3401
+ <li><p> Let <var> contentRangeValue</var> be the <a lt=value for=header>value</a> of the first <a for=/>header</a> whose <a for=header>name</a> is a
3402
+ <a>byte-case-insensitive</a> match for `<code> Content-Range</code> ` in <var> response</var> ’s <a for=response>header list</a> .
3403
+
3404
+ <li><p> If parsing <var> contentRangeValue</var> per <a>single byte content-range</a> fails, then return failure.
3405
+
3406
+ <li><p> Let <var> firstBytePos</var> be the portion of <var> contentRangeValue</var> named
3407
+ first-byte-pos when parsed as <a>single byte content-range</a> , parsed as an integer.
3408
+
3409
+ <li><p> Let <var> lastBytePos</var> be the portion of <var> contentRangeValue</var> named
3410
+ last-byte-pos when parsed as <a>single byte content-range</a> , parsed as an integer.
3411
+
3412
+ <li><p> Let <var> completeLength</var> be the portion of <var> contentRangeValue</var> named
3413
+ complete-length when parsed as <a>single byte content-range</a> .
3414
+
3415
+ <li><p> If <var> completeLength</var> is "<code> *</code> ", then set <var> completeLength</var> to null, otherwise
3416
+ set <var> completeLength</var> to <var> completeLength</var> parsed as an integer.
3417
+
3418
+ <li><p> Return <var> firstBytePos</var> , <var> lastBytePos</var> , and <var> completeLength</var> .
3419
+ </ol>
3420
+
3421
+ <p class=XXX> Parsing as an integer <a href="https://github.com/whatwg/infra/issues/189">infra/189</a>
3422
+ </div>
3423
+
3424
+ <hr>
3425
+
3426
+ <div algorithm>
3427
+ <p> To <dfn>validate a partial response</dfn> , given an integer <var> expectedRangeStart</var> , a
3428
+ <a for=/>response</a> <var> partialResponse</var> , and an optional <a for=/>response</a> <var> previousResponse</var> (default null),
3429
+ run these steps:</p>
3430
+
3431
+ <ol>
3432
+ <li><p> Assert: <var> partialResponse</var> 's <a for=response>status</a> is `206`.
3433
+
3434
+ <li><p> Let <var> responseFirstBytePos</var> , <var ignore> responseLastBytePos</var> , and <var> responseCompleteLength</var> be the
3435
+ result of <a>extracting content-range values</a> from <var> partialResponse</var> . If this fails, then return invalid.
3436
+
3437
+ <li><p> If <var> responseFirstBytePos</var> does not equal <var> expectedRangeStart</var> , then return invalid.
3438
+
3439
+ <li><p> If <var> previousResponse</var> is not null, then:
3440
+
3441
+ <ol>
3442
+ <li><p> For <var> headerName</var> of « `<code> ETag</code> `, `<code> Last-Modified</code> ` »:
3443
+
3444
+ <ol>
3445
+ <li> If <var> previousResponse</var> 's <a for=response>header list</a> <a for="header list">contains</a> <var> headerName</var>
3446
+ and the <a for="header list">combined</a> value of <var> headerName</var>
3447
+ in <var> previousResponse</var> 's <a for=response>header list</a> does not equal the
3448
+ <a for="header list">combined</a> value of <var> headerName</var> in <var> partialResponse</var> 's
3449
+ <a for=response>header list</a> , then return invalid.
3450
+ </ol>
3451
+
3452
+ <li><p> If <var> previousResponse</var> 's <a for=response>status</a> is 206, then:
3453
+
3454
+ <ol>
3455
+ <li><p> Let <var ignore> previousResponseFirstBytePos</var> , <var ignore> previousResponseLastBytePos</var> ,
3456
+ and <var> previousResponseCompleteLength</var> be the result of <a>extracting content-range values</a>
3457
+ from <var> previousResponse</var> . If this fails, then return invalid.
3458
+
3459
+ <li><p> If <var> previousResponseCompleteLength</var> is not null, and
3460
+ <var> responseCompleteLength</var> does not equal <var> previousResponseCompleteLength</var> , then return invalid.
3461
+ </ol>
3462
+ </ol>
3463
+ <li> Return valid.
3464
+ </ol>
3465
+ </div>
3466
+
3467
+ <hr>
3468
+
3395
3469
<p> To <dfn>obtain a copy of the first 1024 bytes of response</dfn> , given a <a for=/>response</a>
3396
3470
<var> response</var> , run these steps:
3397
3471
@@ -3813,6 +3887,45 @@ response <a for=/>headers</a>, the <a for=header>value</a> `<code>*</code>` coun
3813
3887
<a for=/>requests</a> without <a for=/>credentials</a> . For such <a for=/>requests</a> there is no
3814
3888
way to solely match a <a for=/>header name</a> or <a for=/>method</a> that is `<code> *</code> `.
3815
3889
3890
+ <p> <a>ABNF</a> for a <dfn export> single byte content-range</dfn> :
3891
+
3892
+ <pre><code class=lang-abnf>
3893
+ "bytes=" first-byte-pos "-" last-byte-pos "/" complete-length
3894
+ first-byte-pos = 1*DIGIT
3895
+ last-byte-pos = 1*DIGIT
3896
+ complete-length = ( 1*DIGIT / "*" )
3897
+ </code></pre>
3898
+
3899
+ <p class=note> This is a subset of what <a href="https://tools.ietf.org/html/rfc7233#section-3.1">RFC 7233</a> allows.
3900
+
3901
+ <div class="note">
3902
+
3903
+ The above as a railroad diagram:
3904
+
3905
+ <pre class="railroad">
3906
+ T: "bytes="
3907
+ Stack:
3908
+ Sequence:
3909
+ Comment: first-byte-pos
3910
+ OneOrMore:
3911
+ N: digit
3912
+ Comment: /first-byte-pos
3913
+ N: "/"
3914
+ Sequence:
3915
+ Comment: last-byte-pos
3916
+ OneOrMore:
3917
+ N: digit
3918
+ Comment: /last-byte-pos
3919
+ N: "/"
3920
+ Sequence:
3921
+ Comment: complete-length
3922
+ Choice:
3923
+ N: "*"
3924
+ OneOrMore:
3925
+ N: digit
3926
+ Comment: /complete-length
3927
+ </pre>
3928
+ </div>
3816
3929
3817
3930
<h4 id=cors-protocol-and-credentials>CORS protocol and credentials</h4>
3818
3931
0 commit comments