diff --git a/lib/web/fetch/response.js b/lib/web/fetch/response.js index 182e3dc0199..acd063915cf 100644 --- a/lib/web/fetch/response.js +++ b/lib/web/fetch/response.js @@ -146,7 +146,7 @@ class Response { // 4. If body is non-null, then set bodyWithType to the result of extracting body. if (body != null) { const [extractedBody, type] = extractBody(body) - bodyWithType = { body: extractedBody, type } + bodyWithType = { body: extractedBody, type, source: body } } // 5. Perform initialize a response given this, init, and bodyWithType. diff --git a/lib/web/fetch/util.js b/lib/web/fetch/util.js index 8c73f909604..7e6afba3cf1 100644 --- a/lib/web/fetch/util.js +++ b/lib/web/fetch/util.js @@ -1055,6 +1055,11 @@ async function fullyReadBody (body, processBody, processBodyError) { // with taskDestination. const errorSteps = processBodyError + if (typeof body.source === 'string') { + successSteps(new TextEncoder().encode(body.source)) + return + } + // 4. Let reader be the result of getting a reader for body’s stream. // If that threw an exception, then run errorSteps with that // exception and return.