diff options
author | Tomofumi Chiba <tomofumi.chiba@gmail.com> | 2021-06-22 12:21:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 05:21:57 +0200 |
commit | 4f1b1903cfadeeba24e1b0448879fe12682effb9 (patch) | |
tree | 5adf8bd7af8b86052ef555ca7f6ae221515baec0 /cli/tests/045_programmatic_proxy_client.ts | |
parent | 580c9f9ef02f8e8226437137867d3edeb9241b5e (diff) |
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.
Diffstat (limited to 'cli/tests/045_programmatic_proxy_client.ts')
-rw-r--r-- | cli/tests/045_programmatic_proxy_client.ts | 16 |
1 files changed, 16 insertions, 0 deletions
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(); |