fix(BrowserFetcher): fix httpRequest when using proxy against http HOST (#4558)
This patch avoids https-proxy-agent usage when target host protocol is http and proxy is specified. This is a valid scenario for installer but was failing. Fixes #4556
This commit is contained in:
parent
4bcdfc97dd
commit
7faf1c9030
@ -268,17 +268,26 @@ function extractZip(zipPath, folderPath) {
|
|||||||
|
|
||||||
function httpRequest(url, method, response) {
|
function httpRequest(url, method, response) {
|
||||||
/** @type {Object} */
|
/** @type {Object} */
|
||||||
const options = URL.parse(url);
|
let options = URL.parse(url);
|
||||||
options.method = method;
|
options.method = method;
|
||||||
|
|
||||||
const proxyURL = getProxyForUrl(url);
|
const proxyURL = getProxyForUrl(url);
|
||||||
if (proxyURL) {
|
if (proxyURL) {
|
||||||
/** @type {Object} */
|
if (url.startsWith('http:')) {
|
||||||
const parsedProxyURL = URL.parse(proxyURL);
|
const proxy = URL.parse(proxyURL);
|
||||||
parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
|
options = {
|
||||||
|
path: options.href,
|
||||||
|
host: proxy.hostname,
|
||||||
|
port: proxy.port,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
/** @type {Object} */
|
||||||
|
const parsedProxyURL = URL.parse(proxyURL);
|
||||||
|
parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
|
||||||
|
|
||||||
options.agent = new ProxyAgent(parsedProxyURL);
|
options.agent = new ProxyAgent(parsedProxyURL);
|
||||||
options.rejectUnauthorized = false;
|
options.rejectUnauthorized = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestCallback = res => {
|
const requestCallback = res => {
|
||||||
|
Loading…
Reference in New Issue
Block a user