0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -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/", {
redirect: "manual",
}); // will redirect to http://localhost:4545/
assertEquals(response.status, 0);
assertEquals(response.statusText, "");
assertEquals(response.url, "");
assertEquals(response.type, "opaqueredirect");
try {
await response.text();
fail(
"Reponse.text() didn't throw on a filtered response without a body (type opaqueredirect)",
);
} catch (e) {
return;
}
assertEquals(response.status, 301);
assertEquals(response.url, "http://localhost:4546/");
assertEquals(response.type, "default");
assertEquals(response.headers.get("Location"), "http://localhost:4545/");
},
);

View file

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