mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 06:31:15 +00:00
fix(fetch): a consumed body with a non-stream source should result in a disturbed stream (#11217)
This commit is contained in:
parent
513f921219
commit
4bc8fe71db
1 changed files with 9 additions and 7 deletions
|
@ -41,14 +41,16 @@
|
||||||
get stream() {
|
get stream() {
|
||||||
if (!(this.streamOrStatic instanceof ReadableStream)) {
|
if (!(this.streamOrStatic instanceof ReadableStream)) {
|
||||||
const { body, consumed } = this.streamOrStatic;
|
const { body, consumed } = this.streamOrStatic;
|
||||||
|
if (consumed) {
|
||||||
|
this.streamOrStatic = new ReadableStream();
|
||||||
|
this.streamOrStatic.getReader();
|
||||||
|
} else {
|
||||||
this.streamOrStatic = new ReadableStream({
|
this.streamOrStatic = new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
controller.enqueue(body);
|
controller.enqueue(body);
|
||||||
controller.close();
|
controller.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (consumed) {
|
|
||||||
this.streamOrStatic.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.streamOrStatic;
|
return this.streamOrStatic;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue