From b24b99406c373b1e15832ddd8e510f2c7f536ac1 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Thu, 29 Dec 2022 12:14:28 -0300 Subject: [PATCH] Accept extra headers in the downloader module --- packages/hardhat-core/src/internal/util/download.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/hardhat-core/src/internal/util/download.ts b/packages/hardhat-core/src/internal/util/download.ts index 4b7f41314f..31b37f16c6 100644 --- a/packages/hardhat-core/src/internal/util/download.ts +++ b/packages/hardhat-core/src/internal/util/download.ts @@ -20,7 +20,8 @@ function resolveTempFileName(filePath: string): string { export async function download( url: string, filePath: string, - timeoutMillis = 10000 + timeoutMillis = 10000, + extraHeaders: { [name: string]: string } = {} ) { const { pipeline } = await import("stream"); const { getGlobalDispatcher, ProxyAgent, request } = await import("undici"); @@ -47,6 +48,7 @@ export async function download( maxRedirections: 10, method: "GET", headers: { + ...extraHeaders, "User-Agent": `hardhat ${hardhatVersion ?? "(unknown version)"}`, }, });