Skip to content

Commit 8d1e908

Browse files
committed
fix: move to getAgent instead of just using getUrlProxy
1 parent 876084f commit 8d1e908

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

lib/tools-download.js

+5-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-download.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools-download.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from "path";
33
import { performance } from "perf_hooks";
44

55
import * as core from "@actions/core";
6-
import { getProxyUrl } from "@actions/http-client/lib/proxy";
6+
import { HttpClient } from "@actions/http-client";
77
import * as toolcache from "@actions/tool-cache";
88
import { https } from "follow-redirects";
99
import { v4 as uuidV4 } from "uuid";
@@ -186,8 +186,8 @@ async function downloadAndExtractZstdWithStreaming(
186186
tarVersion: tar.TarVersion,
187187
logger: Logger,
188188
): Promise<string> {
189-
// Attempt to detect a proxy URL that should be used for the download.
190-
const downloadUrl = adjustUrlByProxy(codeqlURL) || codeqlURL;
189+
// Get Agent to use (respects proxy settings).
190+
const agent = new HttpClient().getAgent(codeqlURL);
191191

192192
headers = Object.assign(
193193
{ "User-Agent": "CodeQL Action" },
@@ -196,10 +196,11 @@ async function downloadAndExtractZstdWithStreaming(
196196
);
197197
const response = await new Promise<IncomingMessage>((resolve) =>
198198
https.get(
199-
downloadUrl,
199+
codeqlURL,
200200
{
201201
headers,
202202
highWaterMark: STREAMING_HIGH_WATERMARK_BYTES,
203+
agent,
203204
} as unknown as RequestOptions,
204205
(r) => resolve(r),
205206
),
@@ -221,9 +222,3 @@ function sanitizeUrlForStatusReport(url: string): string {
221222
? url
222223
: "sanitized-value";
223224
}
224-
225-
// Auxiliary function to retrieve the proxy URL to use for a given URL, if proxy settings are configured.
226-
function adjustUrlByProxy(url: string): string | undefined {
227-
const proxyUrl = getProxyUrl(new URL(url));
228-
return proxyUrl ? proxyUrl.toString() : undefined;
229-
}

0 commit comments

Comments
 (0)