Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/teeny-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 4 additions & 13 deletions packages/teeny-request/src/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, HTTPAgent>();
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/teeny-request/test/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('agents', () => {
const proxy = 'http://hello.there:8080';
const proxyExpected = {
hostname: 'hello.there',
port: 8080,
port: '8080',
protocol: 'http:',
};

Expand Down
Loading