fix(ext/fetch): Body#bodyUsed for static body (#16080)

This fixes a bug where `Body#bodyUsed` incorrectly returns `false`
for a body that has actually already been consumed, after `Body#body`
is called.
This commit is contained in:
Marcos Casagrande 2022-09-29 17:38:04 +02:00 committed by GitHub
parent 15ea624790
commit 927f4e2e83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View file

@ -90,3 +90,13 @@ Deno.test(function customInspectFunction() {
);
assertStringIncludes(Deno.inspect(Response.prototype), "Response");
});
Deno.test(async function responseBodyUsed() {
const response = new Response("body");
assert(!response.bodyUsed);
await response.text();
assert(response.bodyUsed);
// .body getter is needed so we can test the faulty code path
response.body;
assert(response.bodyUsed);
});