summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Morten <cmorten@users.noreply.github.com>2021-07-05 11:38:12 +0100
committerGitHub <noreply@github.com>2021-07-05 12:38:12 +0200
commita6c840d15020b72326832c19e6a5ac0d95b9bdca (patch)
treebc623f2d76a245d5402e7ee7b47cb1e72028f406
parent3ee0c36453a2591139b7e35882e04c1e706e9253 (diff)
fix(fetch): OPTIONS should be allowed a non-null body (#11242)
-rw-r--r--cli/tests/unit/fetch_test.ts10
-rw-r--r--extensions/fetch/26_fetch.js2
2 files changed, 11 insertions, 1 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 46eceb50c..a84e18367 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -1217,3 +1217,13 @@ unitTest(
await done;
},
);
+
+unitTest(
+ { perms: { net: true } },
+ async function fetchHeadRespBody() {
+ const res = await fetch("http://localhost:4545/echo_server", {
+ method: "HEAD",
+ });
+ assertEquals(res.body, null);
+ },
+);
diff --git a/extensions/fetch/26_fetch.js b/extensions/fetch/26_fetch.js
index 438866fb3..47b07be0b 100644
--- a/extensions/fetch/26_fetch.js
+++ b/extensions/fetch/26_fetch.js
@@ -271,7 +271,7 @@
if (nullBodyStatus(response.status)) {
core.close(resp.responseRid);
} else {
- if (req.method === "HEAD" || req.method === "OPTIONS") {
+ if (req.method === "HEAD" || req.method === "CONNECT") {
response.body = null;
core.close(resp.responseRid);
} else {