Skip to content

Commit

Permalink
refactor: use http-proxy-agent (#10132)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed May 4, 2023
1 parent 8d08b2f commit 7358e9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/browsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"dependencies": {
"debug": "4.3.4",
"extract-zip": "2.0.1",
"http-proxy-agent": "5.0.0",
"https-proxy-agent": "5.0.1",
"progress": "2.0.3",
"proxy-from-env": "1.1.0",
Expand Down
8 changes: 2 additions & 6 deletions packages/browsers/src/httpUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as http from 'http';
import * as https from 'https';
import {URL} from 'url';

import createHttpProxyAgent from 'http-proxy-agent';
import createHttpsProxyAgent from 'https-proxy-agent';
import {getProxyForUrl} from 'proxy-from-env';

Expand Down Expand Up @@ -57,12 +58,7 @@ export function httpRequest(
if (proxyURL) {
const proxy = new URL(proxyURL);
if (proxy.protocol === 'http:') {
options.path = url.href;
options.hostname = proxy.hostname;
options.protocol = proxy.protocol;
options.port = proxy.port;
options.headers ??= {};
options.headers['Host'] ||= url.host;
options.agent = createHttpProxyAgent(proxyURL);
} else {
options.agent = createHttpsProxyAgent({
host: proxy.host,
Expand Down

0 comments on commit 7358e9e

Please sign in to comment.