mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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": {
|
"node_modules/@tootallnate/once": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
@ -4564,8 +4563,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/http-proxy-agent": {
|
"node_modules/http-proxy-agent": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"dev": true,
|
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
|
||||||
"license": "MIT",
|
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tootallnate/once": "2",
|
"@tootallnate/once": "2",
|
||||||
"agent-base": "6",
|
"agent-base": "6",
|
||||||
@ -9320,6 +9319,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "4.3.4",
|
"debug": "4.3.4",
|
||||||
"extract-zip": "2.0.1",
|
"extract-zip": "2.0.1",
|
||||||
|
"http-proxy-agent": "5.0.0",
|
||||||
"https-proxy-agent": "5.0.1",
|
"https-proxy-agent": "5.0.1",
|
||||||
"progress": "2.0.3",
|
"progress": "2.0.3",
|
||||||
"proxy-from-env": "1.1.0",
|
"proxy-from-env": "1.1.0",
|
||||||
@ -10392,6 +10392,7 @@
|
|||||||
"@types/yargs": "17.0.22",
|
"@types/yargs": "17.0.22",
|
||||||
"debug": "4.3.4",
|
"debug": "4.3.4",
|
||||||
"extract-zip": "2.0.1",
|
"extract-zip": "2.0.1",
|
||||||
|
"http-proxy-agent": "5.0.0",
|
||||||
"https-proxy-agent": "5.0.1",
|
"https-proxy-agent": "5.0.1",
|
||||||
"progress": "2.0.3",
|
"progress": "2.0.3",
|
||||||
"proxy-from-env": "1.1.0",
|
"proxy-from-env": "1.1.0",
|
||||||
@ -10611,8 +10612,7 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@tootallnate/once": {
|
"@tootallnate/once": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0"
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@tsconfig/node10": {
|
"@tsconfig/node10": {
|
||||||
"version": "1.0.9",
|
"version": "1.0.9",
|
||||||
@ -12569,7 +12569,8 @@
|
|||||||
},
|
},
|
||||||
"http-proxy-agent": {
|
"http-proxy-agent": {
|
||||||
"version": "5.0.0",
|
"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": {
|
"requires": {
|
||||||
"@tootallnate/once": "2",
|
"@tootallnate/once": "2",
|
||||||
"agent-base": "6",
|
"agent-base": "6",
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "4.3.4",
|
"debug": "4.3.4",
|
||||||
"extract-zip": "2.0.1",
|
"extract-zip": "2.0.1",
|
||||||
|
"http-proxy-agent": "5.0.0",
|
||||||
"https-proxy-agent": "5.0.1",
|
"https-proxy-agent": "5.0.1",
|
||||||
"progress": "2.0.3",
|
"progress": "2.0.3",
|
||||||
"proxy-from-env": "1.1.0",
|
"proxy-from-env": "1.1.0",
|
||||||
|
@ -19,6 +19,7 @@ import * as http from 'http';
|
|||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
|
|
||||||
|
import createHttpProxyAgent from 'http-proxy-agent';
|
||||||
import createHttpsProxyAgent from 'https-proxy-agent';
|
import createHttpsProxyAgent from 'https-proxy-agent';
|
||||||
import {getProxyForUrl} from 'proxy-from-env';
|
import {getProxyForUrl} from 'proxy-from-env';
|
||||||
|
|
||||||
@ -57,12 +58,7 @@ export function httpRequest(
|
|||||||
if (proxyURL) {
|
if (proxyURL) {
|
||||||
const proxy = new URL(proxyURL);
|
const proxy = new URL(proxyURL);
|
||||||
if (proxy.protocol === 'http:') {
|
if (proxy.protocol === 'http:') {
|
||||||
options.path = url.href;
|
options.agent = createHttpProxyAgent(proxyURL);
|
||||||
options.hostname = proxy.hostname;
|
|
||||||
options.protocol = proxy.protocol;
|
|
||||||
options.port = proxy.port;
|
|
||||||
options.headers ??= {};
|
|
||||||
options.headers['Host'] ||= url.host;
|
|
||||||
} else {
|
} else {
|
||||||
options.agent = createHttpsProxyAgent({
|
options.agent = createHttpsProxyAgent({
|
||||||
host: proxy.host,
|
host: proxy.host,
|
||||||
|
Loading…
Reference in New Issue
Block a user