mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: add http.setGlobalProxyFromEnv()
This adds an API to dynamically enable built-in proxy support for all of fetch() and http.request()/https.request(), so that users do not have to be aware of them all and configure them one by one. PR-URL: https://github.com/nodejs/node/pull/60953 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com>
This commit is contained in:
@@ -50,8 +50,8 @@ const tls = require('tls');
|
||||
const {
|
||||
kProxyConfig,
|
||||
checkShouldUseProxy,
|
||||
filterEnvForProxies,
|
||||
kWaitForProxyTunnel,
|
||||
getGlobalAgent,
|
||||
} = require('internal/http');
|
||||
const { Agent: HttpAgent } = require('_http_agent');
|
||||
const {
|
||||
@@ -602,11 +602,7 @@ Agent.prototype._evictSession = function _evictSession(key) {
|
||||
delete this._sessionCache.map[key];
|
||||
};
|
||||
|
||||
const globalAgent = new Agent({
|
||||
keepAlive: true, scheduling: 'lifo', timeout: 5000,
|
||||
// This normalized from both --use-env-proxy and NODE_USE_ENV_PROXY settings.
|
||||
proxyEnv: getOptionValue('--use-env-proxy') ? filterEnvForProxies(process.env) : undefined,
|
||||
});
|
||||
const globalAgent = getGlobalAgent(getOptionValue('--use-env-proxy') ? process.env : undefined, Agent);
|
||||
|
||||
/**
|
||||
* Makes a request to a secure web server.
|
||||
|
||||
Reference in New Issue
Block a user