Skip to content

Commit

Permalink
fix(BrowserFetcher): fix httpRequest when using proxy against http HO…
Browse files Browse the repository at this point in the history
…ST (#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
  • Loading branch information
tenuki authored and aslushnikov committed Jun 10, 2019
1 parent 4bcdfc9 commit 7faf1c9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/BrowserFetcher.js
Expand Up @@ -268,17 +268,26 @@ function extractZip(zipPath, folderPath) {

function httpRequest(url, method, response) {
/** @type {Object} */
const options = URL.parse(url);
let options = URL.parse(url);
options.method = method;

const proxyURL = getProxyForUrl(url);
if (proxyURL) {
/** @type {Object} */
const parsedProxyURL = URL.parse(proxyURL);
parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
if (url.startsWith('http:')) {
const proxy = URL.parse(proxyURL);
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.rejectUnauthorized = false;
options.agent = new ProxyAgent(parsedProxyURL);
options.rejectUnauthorized = false;
}
}

const requestCallback = res => {
Expand Down

0 comments on commit 7faf1c9

Please sign in to comment.