refactor: use http-proxy-agent (#10132)
This commit is contained in:
parent
8d08b2f481
commit
7358e9e92f
13
package-lock.json
generated
13
package-lock.json
generated
@ -1572,7 +1572,6 @@
|
||||
},
|
||||
"node_modules/@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
@ -4564,8 +4563,8 @@
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "5.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
|
||||
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
|
||||
"dependencies": {
|
||||
"@tootallnate/once": "2",
|
||||
"agent-base": "6",
|
||||
@ -9320,6 +9319,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",
|
||||
@ -10392,6 +10392,7 @@
|
||||
"@types/yargs": "17.0.22",
|
||||
"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",
|
||||
@ -10611,8 +10612,7 @@
|
||||
"dev": true
|
||||
},
|
||||
"@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"dev": true
|
||||
"version": "2.0.0"
|
||||
},
|
||||
"@tsconfig/node10": {
|
||||
"version": "1.0.9",
|
||||
@ -12569,7 +12569,8 @@
|
||||
},
|
||||
"http-proxy-agent": {
|
||||
"version": "5.0.0",
|
||||
"dev": true,
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
|
||||
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
|
||||
"requires": {
|
||||
"@tootallnate/once": "2",
|
||||
"agent-base": "6",
|
||||
|
@ -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",
|
||||
|
@ -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';
|
||||
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user