@@ -4194,11 +4194,68 @@ steps:
4194
4194
<a for=/>response</a> <var> response</var> , run these steps:
4195
4195
4196
4196
<ol>
4197
+ <li>
4198
+ <p> If <var> response</var> is a <a>network error</a> , then:
4199
+
4200
+ <ol>
4201
+ <li>
4202
+ <p> Set <var> response</var> 's <a for=response>URL list</a> to « <var>fetchParams</var>' s
4203
+ <a for="fetch params">request</a> 's <a for=request>URL list</a> [0] ».
4204
+
4205
+ <p class=note> This is needed as after <a for=list>cloning</a> <var> fetchParams</var> 's
4206
+ <a for="fetch params">request</a> 's <a for=request>URL list</a> earlier, <var> response</var>
4207
+ might have been set to a <a>network error</a> .</p>
4208
+ </li>
4209
+
4210
+ <li><p> Set <var> response</var> 's <a for=response>timing info</a> to the result of
4211
+ <a>creating an opaque timing info</a> for <var> fetchParams</var> 's
4212
+ <a for="fetch params">timing info</a> .</p></li>
4213
+ </ol>
4214
+ </li>
4215
+
4216
+ <li>
4217
+ <p> Let <var> processResponseDone</var> be the following steps:
4218
+
4219
+ <ol>
4220
+ <li><p> Set <var> fetchParams</var> 's <a for="fetch params">request</a>' s
4221
+ <a for=request>done flag</a> .
4222
+
4223
+ <li><p> If <var> fetchParams</var> 's <a for="fetch params">process response done</a> is not null,
4224
+ then <a>queue a fetch task</a> to run <var> fetchParams</var> 's
4225
+ <a for="fetch params">process response done</a> given <var> response</var> with
4226
+ <var> fetchParams</var> 's <a for="fetch params">task destination</a> .
4227
+ </ol>
4228
+ </li>
4229
+
4197
4230
<li><p> If <var> fetchParams</var> 's <a for="fetch params">process response</a> is non-null, then
4198
4231
<a>queue a fetch task</a> to run <var> fetchParams</var> 's
4199
4232
<a for="fetch params">process response</a> given <var> response</var> , with <var> fetchParams</var> 's
4200
4233
<a for="fetch params">task destination</a> .
4201
4234
4235
+ <li><p> If <var> response</var> 's <a for=response>body</a> is null, then run
4236
+ <var> processResponseDone</var> .
4237
+
4238
+ <li>
4239
+ <p> Otherwise:</p>
4240
+
4241
+ <ol>
4242
+ <li><p> Let <var> transformStream</var> be a new a {{TransformStream}} .
4243
+
4244
+ <li><p> Let <var> identityTransformAlgorithm</var> be an algorithm which, given <var> chunk</var> ,
4245
+ <a for=TransformStream lt=enqueue>enqueues</a> <var> chunk</var> in <var> transformStream</var> .
4246
+
4247
+ <li><p> <a for=TransformStream lt="setting up">Set up</a> <var> transformStream</var> with
4248
+ <a for="TransformStream/set up"><i>transformAlgorithm</i></a> set to <var> identityTransformAlgorithm</var> and
4249
+ <a for="TransformStream/set up"><i>flushAlgorithm</i></a> set to <var> processResponseDone</var> .
4250
+
4251
+ <li><p> Set <var> response</var> 's <a for=response>body</a> to the result of
4252
+ <a for=ReadableStream lt="piping through">piping</a> <var> response</var> 's
4253
+ <a for=response>body</a> through <var> transformStream</var> .
4254
+ </ol>
4255
+
4256
+ <p class=note> This {{TransformStream}} is needed for the purpose of receiving a notification when
4257
+ the stream reaches its end, and is otherwise an <a>identity transform stream</a> .
4258
+
4202
4259
<li>
4203
4260
<p> If <var> fetchParams</var> 's <a for="fetch params">process response end-of-body</a> is non-null,
4204
4261
then:
@@ -4221,24 +4278,13 @@ steps:
4221
4278
</ol>
4222
4279
</ol>
4223
4280
4224
- <p> To <dfn>finalize response</dfn> given a <a for=/>fetch params</a> <var> fetchParams</var> and a
4225
- <a for=/>response</a> <var> response</var> , run these steps:
4226
-
4227
- <ol>
4228
- <li><p> Set <var> fetchParams</var> 's <a for="fetch params">request</a>' s
4229
- <a for=request>done flag</a> .
4230
-
4231
- <li><p> If <var> fetchParams</var> 's <a for="fetch params">process response done</a> is not null,
4232
- then <a>queue a fetch task</a> to run <var> fetchParams</var> 's
4233
- <a for="fetch params">process response done</a> given <var> response</var> ,
4234
- with <var> fetchParams</var> 's <a for="fetch params">task destination</a> .
4235
- </ol>
4236
-
4237
4281
<p> To <dfn export>finalize and report timing</dfn> given a <a for=/>response</a>
4238
4282
<var> response</var> , a <a for=/>global object</a> <var> global</var> , and a <a for=/>string</a>
4239
4283
<var> initiatorType</var> (default "<code> other</code> "), run these steps:
4240
4284
4241
4285
<ol>
4286
+ <li><p> If <var> response</var> is an <a>aborted network error</a> , then return.
4287
+
4242
4288
<li><p> If <var> response</var> 's <a for=response>URL list</a> is null or
4243
4289
<a for=list lt="is empty">empty</a> , then return.
4244
4290
@@ -4248,6 +4294,9 @@ steps:
4248
4294
4249
4295
<li><p> Let <var> cacheState</var> be <var> response</var> 's <a for=response>cache state</a> .
4250
4296
4297
+ <li><p> If <var> originalURL</var> 's <a for=url>scheme</a> is not an <a>HTTP(S) scheme</a> , then
4298
+ return.
4299
+
4251
4300
<li><p> If <var> timingInfo</var> is null, then return.
4252
4301
4253
4302
<li>
@@ -5580,17 +5629,14 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
5580
5629
5581
5630
<li><p> Otherwise, if the bytes transmission for <var> response</var> 's message body is done
5582
5631
normally and <var> stream</var> is <a for=ReadableStream>readable</a> , then
5583
- <a for=ReadableStream>close</a> <var> stream</var> , <a for=/>finalize response</a> for
5584
- <var> fetchParams</var> and <var> response</var> , and abort these in-parallel steps.
5632
+ <a for=ReadableStream>close</a> <var> stream</var> , and abort these in-parallel steps.
5585
5633
</ol>
5586
5634
</ol>
5587
5635
5588
5636
<li>
5589
5637
<p> <a>If aborted</a> , then:
5590
5638
5591
5639
<ol>
5592
- <li> <a for=/>Finalize response</a> for <var> fetchParams</var> and <var> response</var> .
5593
-
5594
5640
<li><p> Let <var> aborted</var> be the termination's aborted flag.
5595
5641
5596
5642
<li>
0 commit comments