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:
parent
513f921219
commit
4bc8fe71db
1 changed files with 9 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue