Skip to content

Commit

Permalink
fetch: limit web streams usage in body mixin methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mert Can Altin committed Apr 13, 2024
1 parent 7a94682 commit c977df5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/web/fetch/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions lib/web/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c977df5

Please sign in to comment.