From 08e9a4ddaa2e3350d76d899edcc07077d54f0acf Mon Sep 17 00:00:00 2001 From: Sergey Bekrin Date: Thu, 11 Apr 2019 19:46:55 +0200 Subject: [PATCH] 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. --- lib/Launcher.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Launcher.js b/lib/Launcher.js index c860956ea64..54f8225c695 100644 --- a/lib/Launcher.js +++ b/lib/Launcher.js @@ -16,6 +16,7 @@ const os = require('os'); const path = require('path'); const http = require('http'); +const https = require('https'); const URL = require('url'); const removeFolder = require('rimraf'); const childProcess = require('child_process'); @@ -382,8 +383,9 @@ function getWSEndpoint(browserURL) { const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); const endpointURL = URL.resolve(browserURL, '/json/version'); + const protocol = endpointURL.startsWith('https') ? https : http; const requestOptions = Object.assign(URL.parse(endpointURL), { method: 'GET' }); - const request = http.request(requestOptions, res => { + const request = protocol.request(requestOptions, res => { let data = ''; if (res.statusCode !== 200) { // Consume response data to free up memory.