From a50dab683f0d902bcfab53ac5a351c661d816354 Mon Sep 17 00:00:00 2001 From: William Perron Date: Thu, 29 Apr 2021 13:56:59 -0400 Subject: fix(op_crate/fetch): infinite loop on fill headers (#10406) Fixes a pesky bug in the fetch implementation where if the init part is specified in `fetch` instead of the `Request` constructor, the fillHeaders function receives two references to the same object, causing it to append to the same list being iterated over. --- cli/tests/unit/fetch_test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cli/tests/unit/fetch_test.ts') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index a46104ff8..e046e9c03 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -447,6 +447,21 @@ unitTest( }, ); +unitTest( + { perms: { net: true } }, + async function fetchSeparateInit(): Promise { + // related to: https://github.com/denoland/deno/issues/10396 + const req = new Request("http://localhost:4545/cli/tests/001_hello.js"); + const init = { + method: "GET", + }; + req.headers.set("foo", "bar"); + const res = await fetch(req, init); + assertEquals(res.status, 200); + await res.text(); + }, +); + unitTest( { perms: { net: true } }, async function fetchInitTypedArrayBody(): Promise { -- cgit v1.2.3