diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-07-28 09:01:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-28 09:01:06 +0200 |
commit | 5cb1d18439f562c8004a941b0f56ed034a44b052 (patch) | |
tree | e0b3ae76685760a50c1089c8885b6f6369d49282 /cli/tests/unit/fetch_test.ts | |
parent | cbfa98ea0bf4ee994bf564671ece514eb4efae1f (diff) |
feat: Deno.createHttpClient allowHost (#19689)
This adds an option to allow using the host header in a fetch call.
Closes https://github.com/denoland/deno/issues/16840
Ref https://github.com/denoland/deno/issues/11017
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index e89abef30..35fe48dca 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -1569,6 +1569,25 @@ Deno.test( }, ); +Deno.test( + { permissions: { net: true, read: true } }, + async function createHttpClientAllowHost() { + const client = Deno.createHttpClient({ + allowHost: true, + }); + const res = await fetch("http://localhost:4545/echo_server", { + headers: { + "host": "example.com", + }, + client, + }); + assert(res.ok); + assertEquals(res.headers.get("host"), "example.com"); + await res.body?.cancel(); + client.close(); + }, +); + Deno.test({ permissions: { read: false } }, async function fetchFilePerm() { await assertRejects(async () => { await fetch(import.meta.resolve("../testdata/subdir/json_1.json")); |