1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 12:58:54 -05:00

fix(op_crates/fetch): redirect: "manual" fetch should return type: "default" response (#8353)

This commit is contained in:
Luca Casonato 2020-11-24 21:00:35 +01:00 committed by GitHub
parent 276f529755
commit 501a31fcf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 20 deletions

View file

@ -693,18 +693,10 @@ unitTest(
const response = await fetch("http://localhost:4546/", { const response = await fetch("http://localhost:4546/", {
redirect: "manual", redirect: "manual",
}); // will redirect to http://localhost:4545/ }); // will redirect to http://localhost:4545/
assertEquals(response.status, 0); assertEquals(response.status, 301);
assertEquals(response.statusText, ""); assertEquals(response.url, "http://localhost:4546/");
assertEquals(response.url, ""); assertEquals(response.type, "default");
assertEquals(response.type, "opaqueredirect"); assertEquals(response.headers.get("Location"), "http://localhost:4545/");
try {
await response.text();
fail(
"Reponse.text() didn't throw on a filtered response without a body (type opaqueredirect)",
);
} catch (e) {
return;
}
}, },
); );

View file

@ -1342,15 +1342,11 @@
}); });
return new Response(null, responseInit); return new Response(null, responseInit);
case "manual": case "manual":
responseInit = {}; // On the web this would return a `opaqueredirect` response, but
responseData.set(responseInit, { // those don't make sense server side. See denoland/deno#8351.
type: "opaqueredirect", return response;
redirected: false,
url: "",
});
return new Response(null, responseInit);
case "follow": case "follow":
// fallthrough // fallthrough
default: { default: {
let redirectUrl = response.headers.get("Location"); let redirectUrl = response.headers.get("Location");
if (redirectUrl == null) { if (redirectUrl == null) {