fix(launcher): support https for browserURL endpoint (#4268)

Certain setups expose remote browser through an HTTPS proxy. This patch
adds support for `https://` urls for `browserURL` option.
This commit is contained in:
Sergey Bekrin 2019-04-11 19:46:55 +02:00 committed by Andrey Lushnikov
parent 19606a3b79
commit 08e9a4ddaa

View File

@ -16,6 +16,7 @@
const os = require('os'); const os = require('os');
const path = require('path'); const path = require('path');
const http = require('http'); const http = require('http');
const https = require('https');
const URL = require('url'); const URL = require('url');
const removeFolder = require('rimraf'); const removeFolder = require('rimraf');
const childProcess = require('child_process'); const childProcess = require('child_process');
@ -382,8 +383,9 @@ function getWSEndpoint(browserURL) {
const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
const endpointURL = URL.resolve(browserURL, '/json/version'); const endpointURL = URL.resolve(browserURL, '/json/version');
const protocol = endpointURL.startsWith('https') ? https : http;
const requestOptions = Object.assign(URL.parse(endpointURL), { method: 'GET' }); const requestOptions = Object.assign(URL.parse(endpointURL), { method: 'GET' });
const request = http.request(requestOptions, res => { const request = protocol.request(requestOptions, res => {
let data = ''; let data = '';
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
// Consume response data to free up memory. // Consume response data to free up memory.