summaryrefslogtreecommitdiff
path: root/ext/fetch/22_body.js
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2023-08-15 09:21:02 +0200
committerGitHub <noreply@github.com>2023-08-15 09:21:02 +0200
commit0fc31d9d657b4ccf24099803d5321182f08f710c (patch)
treeebe525efbe1d33b6daa3a9e8be95ebb53600a4a1 /ext/fetch/22_body.js
parent119526a7a5fef24783e5a7a5f4fb05038b410c88 (diff)
fix(ext/fetch): clone second branch chunks in Body.clone() (#20057)
This PR makes `Body.clone()` spec compliant: https://fetch.spec.whatwg.org/#concept-body-clone > 1, Let « out1, out2 » be the result of [teeing](https://streams.spec.whatwg.org/#readablestream-tee) body’s [stream](https://fetch.spec.whatwg.org/#concept-body-stream). > ... > To tee a [ReadableStream](https://streams.spec.whatwg.org/#readablestream) stream, return ? [ReadableStreamTee](https://streams.spec.whatwg.org/#readable-stream-tee)(stream, true). --- Closes #10994
Diffstat (limited to 'ext/fetch/22_body.js')
-rw-r--r--ext/fetch/22_body.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js
index 9fe00b144..644b9f76f 100644
--- a/ext/fetch/22_body.js
+++ b/ext/fetch/22_body.js
@@ -33,6 +33,7 @@ import {
readableStreamCollectIntoUint8Array,
readableStreamDisturb,
ReadableStreamPrototype,
+ readableStreamTee,
readableStreamThrowIfErrored,
} from "ext:deno_web/06_streams.js";
const primordials = globalThis.__bootstrap.primordials;
@@ -194,7 +195,7 @@ class InnerBody {
* @returns {InnerBody}
*/
clone() {
- const { 0: out1, 1: out2 } = this.stream.tee();
+ const { 0: out1, 1: out2 } = readableStreamTee(this.stream, true);
this.streamOrStatic = out1;
const second = new InnerBody(out2);
second.source = core.deserialize(core.serialize(this.source));