|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | import os from 'os';
|
18 |
| -import https from 'https'; |
| 18 | +import https, { RequestOptions } from 'https'; |
19 | 19 | import ProgressBar from 'progress';
|
| 20 | +import URL from 'url'; |
20 | 21 | import puppeteer from '../node.js';
|
21 | 22 | import { PUPPETEER_REVISIONS } from '../revisions.js';
|
22 | 23 | import { PuppeteerNode } from './Puppeteer.js';
|
| 24 | +import createHttpsProxyAgent, { |
| 25 | + HttpsProxyAgentOptions, |
| 26 | +} from 'https-proxy-agent'; |
| 27 | +import { getProxyForUrl } from 'proxy-from-env'; |
23 | 28 |
|
24 | 29 | const supportedProducts = {
|
25 | 30 | chrome: 'Chromium',
|
@@ -148,16 +153,32 @@ export async function downloadBrowser(): Promise<void> {
|
148 | 153 | }
|
149 | 154 |
|
150 | 155 | function getFirefoxNightlyVersion() {
|
151 |
| - const firefoxVersions = |
| 156 | + const firefoxVersionsUrl = |
152 | 157 | 'https://product-details.mozilla.org/1.0/firefox_versions.json';
|
153 | 158 |
|
| 159 | + const proxyURL = getProxyForUrl(firefoxVersionsUrl); |
| 160 | + |
| 161 | + const requestOptions: RequestOptions = {}; |
| 162 | + |
| 163 | + if (proxyURL) { |
| 164 | + const parsedProxyURL = URL.parse(proxyURL); |
| 165 | + |
| 166 | + const proxyOptions = { |
| 167 | + ...parsedProxyURL, |
| 168 | + secureProxy: parsedProxyURL.protocol === 'https:', |
| 169 | + } as HttpsProxyAgentOptions; |
| 170 | + |
| 171 | + requestOptions.agent = createHttpsProxyAgent(proxyOptions); |
| 172 | + requestOptions.rejectUnauthorized = false; |
| 173 | + } |
| 174 | + |
154 | 175 | const promise = new Promise((resolve, reject) => {
|
155 | 176 | let data = '';
|
156 | 177 | logPolitely(
|
157 |
| - `Requesting latest Firefox Nightly version from ${firefoxVersions}` |
| 178 | + `Requesting latest Firefox Nightly version from ${firefoxVersionsUrl}` |
158 | 179 | );
|
159 | 180 | https
|
160 |
| - .get(firefoxVersions, (r) => { |
| 181 | + .get(firefoxVersionsUrl, requestOptions, (r) => { |
161 | 182 | if (r.statusCode >= 400)
|
162 | 183 | return reject(new Error(`Got status code ${r.statusCode}`));
|
163 | 184 | r.on('data', (chunk) => {
|
|
0 commit comments