diff options
Diffstat (limited to 'extensions/fetch/26_fetch.js')
-rw-r--r-- | extensions/fetch/26_fetch.js | 14 |
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() { |