diff --git a/packages/teeny-request/package.json b/packages/teeny-request/package.json index 0cf9dff35..d69d64ebd 100644 --- a/packages/teeny-request/package.json +++ b/packages/teeny-request/package.json @@ -42,7 +42,7 @@ }, "homepage": "https://github.com/googleapis/google-cloud-node-core/tree/main/packages/teeny-request", "dependencies": { - "http-proxy-agent": "^5.0.0", + "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2", "stream-events": "^1.0.5" diff --git a/packages/teeny-request/src/agents.ts b/packages/teeny-request/src/agents.ts index 2cb72c1d0..bf27f8437 100644 --- a/packages/teeny-request/src/agents.ts +++ b/packages/teeny-request/src/agents.ts @@ -17,8 +17,6 @@ import {Agent as HTTPAgent} from 'http'; import {Agent as HTTPSAgent} from 'https'; -// eslint-disable-next-line n/no-deprecated-api -import {parse} from 'url'; import {Options} from './'; export const pool = new Map(); @@ -83,18 +81,11 @@ export function getAgent( if (proxy && shouldUseProxy) { // tslint:disable-next-line variable-name - let Agent = isHttp - ? require('http-proxy-agent') - : require('https-proxy-agent'); - - if (Agent.HttpsProxyAgent) { - Agent = Agent.HttpsProxyAgent; - } else if (Agent.HttpProxyAgent) { - Agent = Agent.HttpProxyAgent; - } + const {HttpProxyAgent} = require('http-proxy-agent'); + const {HttpsProxyAgent} = require('https-proxy-agent'); - const proxyOpts = {...parse(proxy), ...poolOptions}; - return new Agent(proxyOpts); + const Agent = isHttp ? HttpProxyAgent : HttpsProxyAgent; + return new Agent(proxy, poolOptions); } let key = isHttp ? 'http' : 'https'; diff --git a/packages/teeny-request/test/agents.ts b/packages/teeny-request/test/agents.ts index 755ddc268..0f8deee0e 100644 --- a/packages/teeny-request/test/agents.ts +++ b/packages/teeny-request/test/agents.ts @@ -67,7 +67,7 @@ describe('agents', () => { const proxy = 'http://hello.there:8080'; const proxyExpected = { hostname: 'hello.there', - port: 8080, + port: '8080', protocol: 'http:', };