summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-06-01 14:37:46 +0200
committerGitHub <noreply@github.com>2020-06-01 14:37:46 +0200
commit29db4104c4b05d7eff3a5d74514db0904ea1cd98 (patch)
treeca916fd13f3f856cde0b3a41476e3e022503a272 /cli/js
parent1d3dce9a68c981aded31b4eb12f8a2ec4beecfab (diff)
fix(cli/web): Body.bodyUsed should use IsReadableStreamDisturbed
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/web/body.ts3
-rw-r--r--cli/js/web/streams/internals.ts5
2 files changed, 7 insertions, 1 deletions
diff --git a/cli/js/web/body.ts b/cli/js/web/body.ts
index 7a5b63d32..672b7de5a 100644
--- a/cli/js/web/body.ts
+++ b/cli/js/web/body.ts
@@ -2,6 +2,7 @@ import * as blob from "./blob.ts";
import * as encoding from "./text_encoding.ts";
import * as domTypes from "./dom_types.d.ts";
import { ReadableStreamImpl } from "./streams/readable_stream.ts";
+import { isReadableStreamDisturbed } from "./streams/internals.ts";
import { getHeaderValueParams, hasHeaderValueOf } from "./util.ts";
import { MultipartParser } from "./fetch/multipart.ts";
@@ -116,7 +117,7 @@ export class Body implements domTypes.Body {
}
get bodyUsed(): boolean {
- if (this.body && this.body.locked) {
+ if (this.body && isReadableStreamDisturbed(this.body)) {
return true;
}
return false;
diff --git a/cli/js/web/streams/internals.ts b/cli/js/web/streams/internals.ts
index ff8fc25fe..d0d35a1c3 100644
--- a/cli/js/web/streams/internals.ts
+++ b/cli/js/web/streams/internals.ts
@@ -367,6 +367,11 @@ export function isReadableStreamLocked(stream: ReadableStreamImpl): boolean {
return stream[sym.reader] ? true : false;
}
+export function isReadableStreamDisturbed(stream: ReadableStream): boolean {
+ assert(isReadableStream(stream));
+ return stream[sym.disturbed] ? true : false;
+}
+
export function isTransformStream(
x: unknown
): x is TransformStreamImpl<any, any> {