mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 05:05:39 +00:00
feat(cli): add --disable-http-https-agents-cache flag
This commit is contained in:
@@ -225,6 +225,11 @@ const builder = async (yargs) => {
|
||||
description: 'Disable all proxy settings (both collection-defined and system proxies)',
|
||||
default: false
|
||||
})
|
||||
.option('disable-http-https-agents-cache', {
|
||||
type: 'boolean',
|
||||
description: 'Disable HTTP/HTTPS agent caching — creates a fresh agent for every request',
|
||||
default: false
|
||||
})
|
||||
.option('delay', {
|
||||
type: 'number',
|
||||
description: 'Delay between each requests (in miliseconds)'
|
||||
@@ -330,6 +335,7 @@ const handler = async function (argv) {
|
||||
reporterSkipBody,
|
||||
clientCertConfig,
|
||||
noproxy,
|
||||
disableHttpHttpsAgentsCache,
|
||||
delay,
|
||||
tags: includeTags,
|
||||
excludeTags,
|
||||
@@ -531,6 +537,9 @@ const handler = async function (argv) {
|
||||
if (noproxy) {
|
||||
options['noproxy'] = true;
|
||||
}
|
||||
if (disableHttpHttpsAgentsCache) {
|
||||
options['disableHttpHttpsAgentsCache'] = true;
|
||||
}
|
||||
if (verbose) {
|
||||
options['verbose'] = true;
|
||||
}
|
||||
|
||||
@@ -348,6 +348,7 @@ const runSingleRequest = async function (
|
||||
const insecure = get(options, 'insecure', false);
|
||||
const noproxy = get(options, 'noproxy', false);
|
||||
const cachedSystemProxy = get(options, 'cachedSystemProxy', null);
|
||||
const disableCache = get(options, 'disableHttpHttpsAgentsCache', false);
|
||||
const httpsAgentRequestFields = {};
|
||||
|
||||
if (insecure) {
|
||||
@@ -459,15 +460,15 @@ const runSingleRequest = async function (
|
||||
// Only set the agent needed for the request protocol
|
||||
if (socksEnabled) {
|
||||
if (isHttpsRequest) {
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: SocksProxyAgent, options: tlsOptions, proxyUri });
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: SocksProxyAgent, options: tlsOptions, proxyUri, disableCache });
|
||||
} else {
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: SocksProxyAgent, options: httpAgentOptions, proxyUri });
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: SocksProxyAgent, options: httpAgentOptions, proxyUri, disableCache });
|
||||
}
|
||||
} else {
|
||||
if (isHttpsRequest) {
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri });
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri, disableCache });
|
||||
} else {
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: httpAgentOptions, proxyUri });
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: httpAgentOptions, proxyUri, disableCache });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -479,7 +480,7 @@ const runSingleRequest = async function (
|
||||
try {
|
||||
if (http_proxy?.length && !isHttpsRequest) {
|
||||
new URL(http_proxy);
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: httpAgentOptions, proxyUri: http_proxy });
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: httpAgentOptions, proxyUri: http_proxy, disableCache });
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Invalid system http_proxy');
|
||||
@@ -487,7 +488,7 @@ const runSingleRequest = async function (
|
||||
try {
|
||||
if (https_proxy?.length && isHttpsRequest) {
|
||||
new URL(https_proxy);
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri: https_proxy });
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri: https_proxy, disableCache });
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Invalid system https_proxy');
|
||||
@@ -501,9 +502,9 @@ const runSingleRequest = async function (
|
||||
|
||||
if (!request.httpAgent && !request.httpsAgent) {
|
||||
if (isHttpsRequest) {
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: https.Agent, options: tlsOptions });
|
||||
request.httpsAgent = getOrCreateAgent({ AgentClass: https.Agent, options: tlsOptions, disableCache });
|
||||
} else {
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: http.Agent, options: httpAgentOptions });
|
||||
request.httpAgent = getOrCreateHttpAgent({ AgentClass: http.Agent, options: httpAgentOptions, disableCache });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user