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/dts/lib.deno.unstable.d.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'cli/dts') diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 828211c5b..1d01a748e 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1089,6 +1089,17 @@ declare namespace Deno { /** A certificate authority to use when validating TLS certificates. Certificate data must be PEM encoded. */ caData?: string; + proxy?: Proxy; + } + + export interface Proxy { + url: string; + basicAuth?: BasicAuth; + } + + export interface BasicAuth { + username: string; + password: string; } /** **UNSTABLE**: New API, yet to be vetted. @@ -1096,7 +1107,12 @@ declare namespace Deno { * * ```ts * const client = Deno.createHttpClient({ caData: await Deno.readTextFile("./ca.pem") }); - * const req = await fetch("https://myserver.com", { client }); + * const response = await fetch("https://myserver.com", { client }); + * ``` + * + * ```ts + * const client = Deno.createHttpClient({ proxy: { url: "http://myproxy.com:8080" } }); + * const response = await fetch("https://myserver.com", { client }); * ``` */ export function createHttpClient( -- cgit v1.2.3