From 4f1b1903cfadeeba24e1b0448879fe12682effb9 Mon Sep 17 00:00:00 2001 From: Tomofumi Chiba Date: Tue, 22 Jun 2021 12:21:57 +0900 Subject: feat(fetch): add programmatic proxy (#10907) This commit adds new options to unstable "Deno.createHttpClient" API. "proxy" and "basicAuth" options were added that allow to use custom proxy when client instance is passed to "fetch" API. --- cli/tests/045_programmatic_proxy_client.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cli/tests/045_programmatic_proxy_client.ts (limited to 'cli/tests/045_programmatic_proxy_client.ts') diff --git a/cli/tests/045_programmatic_proxy_client.ts b/cli/tests/045_programmatic_proxy_client.ts new file mode 100644 index 000000000..50884407d --- /dev/null +++ b/cli/tests/045_programmatic_proxy_client.ts @@ -0,0 +1,16 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. + +const client = Deno.createHttpClient({ + proxy: { + url: "http://localhost:4555", + basicAuth: { username: "username", password: "password" }, + }, +}); + +const res = await fetch( + "http://localhost:4545/test_util/std/examples/colors.ts", + { client }, +); +console.log(`Response http: ${await res.text()}`); + +client.close(); -- cgit v1.2.3