0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(fetch): a consumed body with a non-stream source should result in a disturbed stream (#11217)

This commit is contained in:
Andreu Botella 2021-07-02 11:34:12 +02:00 committed by GitHub
parent 513f921219
commit 4bc8fe71db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,14 +41,16 @@
get stream() {
if (!(this.streamOrStatic instanceof ReadableStream)) {
const { body, consumed } = this.streamOrStatic;
this.streamOrStatic = new ReadableStream({
start(controller) {
controller.enqueue(body);
controller.close();
},
});
if (consumed) {
this.streamOrStatic.cancel();
this.streamOrStatic = new ReadableStream();
this.streamOrStatic.getReader();
} else {
this.streamOrStatic = new ReadableStream({
start(controller) {
controller.enqueue(body);
controller.close();
},
});
}
}
return this.streamOrStatic;