Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeError]: Fix when constructor is calling new instances #795

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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 lib/agent/https_ocsp_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SocketUtil = require('./socket_util');
* @constructor
*/
function HttpsOcspAgent(options) {
const agent = HttpsAgent.apply(this, [options]);
const agent = new HttpsAgent(options);
agent.createConnection = function (port, host, options) {
// make sure the 'options' variables references the argument that actually
// contains the options
Expand Down
16 changes: 4 additions & 12 deletions lib/http/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const zlib = require('zlib');
const Util = require('../util');
const Logger = require('../logger');
const axios = require('axios');
const URL = require('node:url').URL;
const URL = require('url');

const DEFAULT_REQUEST_TIMEOUT = 360000;

Expand Down Expand Up @@ -202,13 +202,6 @@ function prepareRequestOptions(options) {

const params = options.params;

let mock;
if (this._connectionConfig.agentClass) {
mock = {
agentClass: this._connectionConfig.agentClass
};
}
const backoffStrategy = this.constructExponentialBackoffStrategy();
const requestOptions = {
method: options.method,
url: options.url,
Expand All @@ -217,15 +210,14 @@ function prepareRequestOptions(options) {
params: params,
timeout: timeout,
requestOCSP: true,
retryDelay: backoffStrategy,
rejectUnauthorized: true,
// we manually parse jsons or other structures from the server so they need to be text
responseType: options.responseType || 'text',
};

const url = new URL(options.url);
const url = new URL.URL(options.url);
const isHttps = url.protocol === 'https:';
const agent = this.getAgent(url, this._connectionConfig.getProxy(), mock);
const agent = this.getAgent(url, this._connectionConfig.getProxy());
if (isHttps) {
requestOptions.httpsAgent = agent;
} else {
Expand Down Expand Up @@ -301,4 +293,4 @@ function normalizeResponse(response) {
}

return response;
}
}
Loading