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_proxy_test.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_proxy_test.ts')
-rw-r--r-- | cli/tests/045_proxy_test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/045_proxy_test.ts b/cli/tests/045_proxy_test.ts index c7ba5e967..6e338f4fc 100644 --- a/cli/tests/045_proxy_test.ts +++ b/cli/tests/045_proxy_test.ts @@ -15,6 +15,11 @@ async function proxyServer(): Promise<void> { async function proxyRequest(req: ServerRequest): Promise<void> { console.log(`Proxy request to: ${req.url}`); + const proxyAuthorization = req.headers.get("proxy-authorization"); + if (proxyAuthorization) { + console.log(`proxy-authorization: ${proxyAuthorization}`); + req.headers.delete("proxy-authorization"); + } const resp = await fetch(req.url, { method: req.method, headers: req.headers, @@ -110,9 +115,28 @@ async function testModuleDownloadNoProxy(): Promise<void> { http.close(); } +async function testFetchProgrammaticProxy(): Promise<void> { + const c = Deno.run({ + cmd: [ + Deno.execPath(), + "run", + "--quiet", + "--reload", + "--allow-net=localhost:4545,localhost:4555", + "--unstable", + "045_programmatic_proxy_client.ts", + ], + stdout: "piped", + }); + const status = await c.status(); + assertEquals(status.code, 0); + c.close(); +} + proxyServer(); await testFetch(); await testModuleDownload(); await testFetchNoProxy(); await testModuleDownloadNoProxy(); +await testFetchProgrammaticProxy(); Deno.exit(0); |