summaryrefslogtreecommitdiff
path: root/extensions/fetch/22_body.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/fetch/22_body.js')
-rw-r--r--extensions/fetch/22_body.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/extensions/fetch/22_body.js b/extensions/fetch/22_body.js
index f0c7ac8bd..dcf1128a7 100644
--- a/extensions/fetch/22_body.js
+++ b/extensions/fetch/22_body.js
@@ -20,7 +20,8 @@
const { parseFormData, formDataFromEntries, encodeFormData } =
globalThis.__bootstrap.formData;
const mimesniff = globalThis.__bootstrap.mimesniff;
- const { isReadableStreamDisturbed } = globalThis.__bootstrap.streams;
+ const { isReadableStreamDisturbed, errorReadableStream } =
+ globalThis.__bootstrap.streams;
class InnerBody {
/** @type {ReadableStream<Uint8Array> | { body: Uint8Array, consumed: boolean }} */
@@ -106,6 +107,22 @@
}
}
+ cancel(error) {
+ if (this.streamOrStatic instanceof ReadableStream) {
+ this.streamOrStatic.cancel(error);
+ } else {
+ this.streamOrStatic.consumed = true;
+ }
+ }
+
+ error(error) {
+ if (this.streamOrStatic instanceof ReadableStream) {
+ errorReadableStream(this.streamOrStatic, error);
+ } else {
+ this.streamOrStatic.consumed = true;
+ }
+ }
+
/**
* @returns {InnerBody}
*/