mirror of
https://github.com/denoland/deno
synced 2024-10-30 02:21:11 +00:00
fix(fetch): network error on multiple redirects (#5985)
This commit is contained in:
parent
ecb94c06e9
commit
08552fc6b9
3 changed files with 13 additions and 7 deletions
|
@ -288,6 +288,7 @@ export async function fetch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let responseInit: ResponseInit = {};
|
||||||
while (remRedirectCount) {
|
while (remRedirectCount) {
|
||||||
const fetchResponse = await sendFetchReq(url, method, headers, body);
|
const fetchResponse = await sendFetchReq(url, method, headers, body);
|
||||||
|
|
||||||
|
@ -314,7 +315,7 @@ export async function fetch(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let responseInit: ResponseInit = {
|
responseInit = {
|
||||||
status: fetchResponse.status,
|
status: fetchResponse.status,
|
||||||
statusText: fetchResponse.statusText,
|
statusText: fetchResponse.statusText,
|
||||||
headers: fetchResponse.headers,
|
headers: fetchResponse.headers,
|
||||||
|
@ -374,6 +375,12 @@ export async function fetch(
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return a network error due to too many redirections
|
|
||||||
throw notImplemented();
|
responseData.set(responseInit, {
|
||||||
|
type: "error",
|
||||||
|
redirected: false,
|
||||||
|
url: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Response(null, responseInit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,14 +245,13 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
// FIXME(bartlomieju):
|
|
||||||
// The feature below is not implemented, but the test should work after implementation
|
|
||||||
ignore: true,
|
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithInfRedirection(): Promise<void> {
|
async function fetchWithInfRedirection(): Promise<void> {
|
||||||
const response = await fetch("http://localhost:4549/cli/tests"); // will redirect to the same place
|
const response = await fetch("http://localhost:4549/cli/tests"); // will redirect to the same place
|
||||||
assertEquals(response.status, 0); // network error
|
assertEquals(response.status, 0); // network error
|
||||||
|
assertEquals(response.type, "error");
|
||||||
|
assertEquals(response.ok, false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ def start(s):
|
||||||
def spawn():
|
def spawn():
|
||||||
servers = (server(), redirect_server(), another_redirect_server(),
|
servers = (server(), redirect_server(), another_redirect_server(),
|
||||||
double_redirects_server(), https_server(),
|
double_redirects_server(), https_server(),
|
||||||
absolute_redirect_server())
|
absolute_redirect_server(), inf_redirects_server())
|
||||||
# In order to wait for each of the servers to be ready, we try connecting to
|
# In order to wait for each of the servers to be ready, we try connecting to
|
||||||
# them with a tcp socket.
|
# them with a tcp socket.
|
||||||
for running_server in servers:
|
for running_server in servers:
|
||||||
|
|
Loading…
Reference in a new issue