mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
38 lines
934 B
JavaScript
38 lines
934 B
JavaScript
// Tests that http.setGlobalProxyFromEnv() works with https.request().
|
|
|
|
import * as common from '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { startTestServers, checkProxiedRequest } from '../common/proxy-server.js';
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('Needs crypto');
|
|
}
|
|
|
|
const { proxyLogs, httpsEndpoint: { requestUrl, serverHost }, proxyUrl, shutdown } = await startTestServers({
|
|
httpsEndpoint: true,
|
|
});
|
|
|
|
await checkProxiedRequest({
|
|
REQUEST_URL: requestUrl,
|
|
SET_GLOBAL_PROXY: JSON.stringify({
|
|
https_proxy: proxyUrl,
|
|
}),
|
|
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'fake-startcom-root-cert.pem'),
|
|
}, {
|
|
stdout: 'Hello world',
|
|
});
|
|
|
|
shutdown();
|
|
|
|
const expectedLogs = [{
|
|
method: 'CONNECT',
|
|
url: serverHost,
|
|
headers: {
|
|
'proxy-connection': 'keep-alive',
|
|
'host': serverHost,
|
|
},
|
|
}];
|
|
|
|
assert.deepStrictEqual(proxyLogs, expectedLogs);
|