diff options
author | William Perron <hey@wperron.io> | 2021-04-29 13:56:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 13:56:59 -0400 |
commit | a50dab683f0d902bcfab53ac5a351c661d816354 (patch) | |
tree | 09a7cc9a7240a87abacda11a4809f859364e7383 /cli/tests/unit/fetch_test.ts | |
parent | 0ac2a17a0fdb19672058c7e6449c686e2a18366e (diff) |
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.
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ -449,6 +449,21 @@ unitTest( unitTest( { perms: { net: true } }, + async function fetchSeparateInit(): Promise<void> { + // 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<void> { const data = "Hello World"; const response = await fetch("http://localhost:4545/echo_server", { |