You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. [=ReadableStream/error=] |newStream| with a {{TypeError}}.
1605
+
1. [=ReadableStreamDefaultReader/Read a chunk=] from |reader| given |readRequest|.
1606
+
1. Let |cancelAlgorithm| be an action that [=ReadableStreamDefaultReader/cancels=] |reader|.
1594
1607
1. Let |highWaterMark| be a non-negative, non-NaN number, chosen by the user agent.
1595
1608
1. Let |sizeAlgorithm| be an algorithm that accepts a [=chunk=] object and returns a non-negative, non-NaN, non-infinite number, chosen by the user agent.
1596
-
1. Let |pull| be an action that runs these subsubsteps:
1597
-
1. Let |promise| be the result of [=read a chunk|reading a chunk=] from |response|'s [=response/body=]'s [=stream=] with |reader|.
1598
-
1. When |promise| is fulfilled with an object whose `done` property is false and whose `value` property is a `Uint8Array` object, append the bytes represented by the `value` property to |bytes| and perform ! [=DetachArrayBuffer=] with the `ArrayBuffer` object wrapped by the `value` property.
1599
-
1. When |promise| is fulfilled with an object whose `done` property is true, set |end-of-body| to true.
1600
-
1. When |promise| is fulfilled with a value that matches with neither of the above patterns, or |promise| is rejected, [=ReadableStream/error=] |newStream| with a `TypeError`.
1601
-
1. Let |cancel| be an action that [=ReadableStream/cancels=] |response|'s [=response/body=]'s [=stream=] with |reader|.
1602
-
1. Let |newStream| be the result of [=ReadableStream/construct a ReadableStream object=] with |highWaterMark|, |sizeAlgorithm|, |pull|, and |cancel| in |targetRealm|.
1609
+
1. Let |newStream| be the result of [=ReadableStream/creating=] a {{ReadableStream}} with <a for=ReadableStream/create><var ignore>pullAlgorithm</var></a> set to |pullAlgorithm|, <a for=ReadableStream/create><var ignore>cancelAlgorithm</var></a> set to |cancelAlgorithm|, <a for=ReadableStream/create><var ignore>highWaterMark</var></a> set to |highWaterMark|, and <a for=ReadableStream/create><var ignore>sizeAlgorithm</var></a> set to |sizeAlgorithm|, in |targetRealm|.
1603
1610
1. Set |potentialResponse|'s [=response/body=] to a new [=/body=] whose [=stream=] is |newStream|.
1604
1611
1. Run these subsubsteps repeatedly [=in parallel=] while |done| is false:
1605
-
1. If |newStream| is [=errored=], then set |done| to true.
1612
+
1. If |newStream| is [=ReadableStream/errored=], then set |done| to true.
1606
1613
1. Otherwise, if |bytes| is empty and |end-of-body| is true, then [=ReadableStream/close=] |newStream| and set |done| to true.
1607
1614
1. Otherwise, if |bytes| is not empty, run these subsubsubsteps:
1608
1615
1. Let |chunk| be a subsequence of |bytes| starting from the beginning of |bytes|.
1609
1616
1. Remove |chunk| from |bytes|.
1610
-
1. Let |buffer| be an `ArrayBuffer` object created in |targetRealm| and containing |chunk|.
1611
-
1. [=ReadableStream/Enqueue=] a `Uint8Array` object created in |targetRealm| and wrapping |buffer| to |newStream|.
1617
+
1. Let |buffer| be an {{ArrayBuffer}} object created in |targetRealm| and containing |chunk|.
1618
+
1. [=ReadableStream/Enqueue=] a {{Uint8Array}} object created in |targetRealm| and wrapping |buffer| to |newStream|.
1612
1619
1613
1620
Note: These substeps are meant to produce the observable equivalent of "piping" |response|'s [=response/body=]'s [=stream=] into |potentialResponse|.
1. Let |bodyReadPromise| be [=a promise resolved with=] undefined.
1977
1984
1. If |innerResponse|'s [=response/body=] is non-null, run these substeps:
1978
1985
1. Let |stream| be |innerResponse|'s [=response/body=]'s [=body/stream=].
1979
-
1. Let |reader| be the result of [=ReadableStream/get a reader|getting a reader=] for |stream|.
1980
-
1. Set |bodyReadPromise| to the result of [=Read all bytes|reading all bytes=] from |stream| with |reader|.
1986
+
1. Let |reader| be the result of [=ReadableStream/getting a reader=] for |stream|.
1987
+
1. Set |bodyReadPromise| to the result of [=ReadableStreamDefaultReader/reading all bytes=] from |reader|.
1981
1988
1982
1989
Note: This ensures that |innerResponse|'s [=response/body=] is [=Body/locked=], and we have a full buffered copy of the body in |clonedResponse|. An implementation could optimize by streaming directly to disk rather than memory.
0 commit comments