summaryrefslogtreecommitdiff
path: root/extensions/fetch/26_fetch.js
diff options
context:
space:
mode:
authorJimmy Wärting <jimmy@warting.se>2021-07-05 15:34:37 +0200
committerGitHub <noreply@github.com>2021-07-05 15:34:37 +0200
commit2c0b0e45b72ef1b5d7fa95e1e110d07ddbc720f7 (patch)
tree3b54a6f1f156f8d105cf41ac290035c8b5f8f1c9 /extensions/fetch/26_fetch.js
parentea87d860beda7cd40eb6857199a00e5ba8700fd2 (diff)
refactor: asynchronous blob backing store (#10969)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'extensions/fetch/26_fetch.js')
-rw-r--r--extensions/fetch/26_fetch.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/extensions/fetch/26_fetch.js b/extensions/fetch/26_fetch.js
index 47b07be0b..a33187344 100644
--- a/extensions/fetch/26_fetch.js
+++ b/extensions/fetch/26_fetch.js
@@ -152,15 +152,18 @@
if (req.body !== null) {
if (req.body.streamOrStatic instanceof ReadableStream) {
- if (req.body.length === null) {
+ if (req.body.length === null || req.body.source instanceof Blob) {
reqBody = req.body.stream;
} else {
const reader = req.body.stream.getReader();
const r1 = await reader.read();
- if (r1.done) throw new TypeError("Unreachable");
- reqBody = r1.value;
- const r2 = await reader.read();
- if (!r2.done) throw new TypeError("Unreachable");
+ if (r1.done) {
+ reqBody = new Uint8Array(0);
+ } else {
+ reqBody = r1.value;
+ const r2 = await reader.read();
+ if (!r2.done) throw new TypeError("Unreachable");
+ }
}
} else {
req.body.streamOrStatic.consumed = true;
@@ -174,6 +177,7 @@
headers: req.headerList,
clientRid: req.clientRid,
hasBody: reqBody !== null,
+ bodyLength: req.body?.length,
}, reqBody instanceof Uint8Array ? reqBody : null);
function onAbort() {