summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-11-24 21:00:35 +0100
committerGitHub <noreply@github.com>2020-11-24 21:00:35 +0100
commit501a31fcf3566788370e45bfb174547706f39337 (patch)
tree31b8360a7558574b04403c062e6001f0895790f1
parent276f5297556097461e0b63f2b958d825c1c857ab (diff)
fix(op_crates/fetch): `redirect: "manual"` fetch should return `type: "default"` response (#8353)
-rw-r--r--cli/tests/unit/fetch_test.ts16
-rw-r--r--op_crates/fetch/26_fetch.js12
2 files changed, 8 insertions, 20 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 681eefad4..99b7531a3 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -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/");
},
);
diff --git a/op_crates/fetch/26_fetch.js b/op_crates/fetch/26_fetch.js
index d0bc6d979..95ee96812 100644
--- a/op_crates/fetch/26_fetch.js
+++ b/op_crates/fetch/26_fetch.js
@@ -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) {