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,11 +268,19 @@ 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) {
|
||||||
|
if (url.startsWith('http:')) {
|
||||||
|
const proxy = URL.parse(proxyURL);
|
||||||
|
options = {
|
||||||
|
path: options.href,
|
||||||
|
host: proxy.hostname,
|
||||||
|
port: proxy.port,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
/** @type {Object} */
|
/** @type {Object} */
|
||||||
const parsedProxyURL = URL.parse(proxyURL);
|
const parsedProxyURL = URL.parse(proxyURL);
|
||||||
parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
|
parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
|
||||||
@ -280,6 +288,7 @@ function httpRequest(url, method, response) {
|
|||||||
options.agent = new ProxyAgent(parsedProxyURL);
|
options.agent = new ProxyAgent(parsedProxyURL);
|
||||||
options.rejectUnauthorized = false;
|
options.rejectUnauthorized = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const requestCallback = res => {
|
const requestCallback = res => {
|
||||||
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location)
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location)
|
||||||
|
Loading…
Reference in New Issue
Block a user