mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
fix: fetch closes unused body (#4393)
This commit makes sure that "httpBody" resource is closed in case of redirections in fetch API.
This commit is contained in:
parent
49541a04d2
commit
7d0b77440e
2 changed files with 3 additions and 8 deletions
|
@ -174,8 +174,6 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
// TODO(bartlomieju): leaking resources
|
|
||||||
skip: true,
|
|
||||||
perms: { net: true }
|
perms: { net: true }
|
||||||
},
|
},
|
||||||
async function fetchWithRedirection(): Promise<void> {
|
async function fetchWithRedirection(): Promise<void> {
|
||||||
|
@ -190,8 +188,6 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
// TODO: leaking resources
|
|
||||||
skip: true,
|
|
||||||
perms: { net: true }
|
perms: { net: true }
|
||||||
},
|
},
|
||||||
async function fetchWithRelativeRedirection(): Promise<void> {
|
async function fetchWithRelativeRedirection(): Promise<void> {
|
||||||
|
@ -451,8 +447,6 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
// TODO: leaking resources
|
|
||||||
skip: true,
|
|
||||||
perms: { net: true }
|
perms: { net: true }
|
||||||
},
|
},
|
||||||
async function fetchWithManualRedirection(): Promise<void> {
|
async function fetchWithManualRedirection(): Promise<void> {
|
||||||
|
@ -476,8 +470,6 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
// TODO: leaking resources
|
|
||||||
skip: true,
|
|
||||||
perms: { net: true }
|
perms: { net: true }
|
||||||
},
|
},
|
||||||
async function fetchWithErrorRedirection(): Promise<void> {
|
async function fetchWithErrorRedirection(): Promise<void> {
|
||||||
|
|
|
@ -531,6 +531,9 @@ export async function fetch(
|
||||||
redirected
|
redirected
|
||||||
);
|
);
|
||||||
if ([301, 302, 303, 307, 308].includes(response.status)) {
|
if ([301, 302, 303, 307, 308].includes(response.status)) {
|
||||||
|
// We won't use body of received response, so close it now
|
||||||
|
// otherwise it will be kept in resource table.
|
||||||
|
close(fetchResponse.bodyRid);
|
||||||
// We're in a redirect status
|
// We're in a redirect status
|
||||||
switch ((init && init.redirect) || "follow") {
|
switch ((init && init.redirect) || "follow") {
|
||||||
case "error":
|
case "error":
|
||||||
|
|
Loading…
Add table
Reference in a new issue