mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-09-20 12:18:48 +00:00
+6
-16
@@ -1,18 +1,8 @@
|
||||
import { ProxyAgent, type RequestInit, fetch as undiciFetch } from "undici";
|
||||
|
||||
export function getProxyAgent() {
|
||||
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
|
||||
if (httpProxy) {
|
||||
return new ProxyAgent(httpProxy);
|
||||
}
|
||||
|
||||
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
if (httpsProxy) {
|
||||
return new ProxyAgent(httpsProxy);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
import {
|
||||
EnvHttpProxyAgent,
|
||||
type RequestInit,
|
||||
fetch as undiciFetch,
|
||||
} from "undici";
|
||||
|
||||
export const fetch = async (url: string, opts: RequestInit) => {
|
||||
// Merge timeout signal with any existing signal from opts
|
||||
@@ -23,7 +13,7 @@ export const fetch = async (url: string, opts: RequestInit) => {
|
||||
: timeoutSignal;
|
||||
|
||||
return await undiciFetch(url, {
|
||||
dispatcher: getProxyAgent(),
|
||||
dispatcher: new EnvHttpProxyAgent(),
|
||||
...opts,
|
||||
signal: mergedSignal,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user