Skip to content

Commit

Permalink
Revert "EPMRPP-91841 || HTTPS proxy support for client (#205)"
Browse files Browse the repository at this point in the history
This reverts commit dfffa3d.
  • Loading branch information
AmsterGet committed Sep 16, 2024
1 parent dccb1ce commit 72695fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
27 changes: 7 additions & 20 deletions lib/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const axios = require('axios');
const axiosRetry = require('axios-retry').default;
const http = require('http');
const https = require('https');
const { HttpsProxyAgent } = require('https-proxy-agent');

const DEFAULT_MAX_CONNECTION_TIME_MS = 30000;

Expand Down Expand Up @@ -63,25 +62,13 @@ method: ${method}`,
return acc;
}, {});

const { protocol } = new URL(this.baseURL);
const isHttps = /https:?/;
const isHttpsRequest = isHttps.test(protocol);
const agentOptions = this.restClientConfig.agent;

if (agentOptions) {
if ('agent' in this.restClientConfig) {
const { protocol } = new URL(this.baseURL);
const isHttps = /https:?/;
const isHttpsRequest = isHttps.test(protocol);
config[isHttpsRequest ? 'httpsAgent' : 'httpAgent'] = isHttpsRequest
? new https.Agent(agentOptions)
: new http.Agent(agentOptions);
}

if (config.proxy && isHttpsRequest) {
const { auth, protocol: proxyProtocol, host, port } = config.proxy;
const authString = auth ? `${auth.username}:${auth.password}@` : '';
const proxyUrl = `${proxyProtocol}://${authString}${host}:${port}`;

config.httpsAgent = new HttpsProxyAgent(proxyUrl, agentOptions);

config.proxy = false;
? new https.Agent(this.restClientConfig.agent)
: new http.Agent(this.restClientConfig.agent);
}

return config;
Expand Down Expand Up @@ -157,7 +144,7 @@ const addLogger = (debug) => {
const status = response ? response.status : null;

console.log(
`Response ${status ? `status=${status}` : `message='${error.message}'`} url=${
`Response ${status ? 'status=' + status : "message='" + error.message + "'"} url=${
config.url
} time=${date.valueOf() - config.startTime}ms [${date.toISOString()}]`,
);
Expand Down
28 changes: 3 additions & 25 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"glob": "^8.1.0",
"ini": "^2.0.0",
"uniqid": "^5.4.0",
"uuid": "^9.0.1",
"https-proxy-agent": "7.0.4"
"uuid": "^9.0.1"
},
"license": "Apache-2.0",
"devDependencies": {
Expand Down

0 comments on commit 72695fb

Please sign in to comment.