summaryrefslogtreecommitdiff
path: root/lib/https.js
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2020-11-17 13:10:49 +0100
committerNode.js GitHub Bot <github-bot@iojs.org>2020-12-27 17:30:09 +0000
commitaabbf3011b59c6412508086e7a831c02cf3a21aa (patch)
tree495dd8c703a7ebd3bed38c9d48835b51885011a7 /lib/https.js
parent6c50d744b311e4ed0ca73d6869abd9bb68d696c6 (diff)
downloadnode-new-aabbf3011b59c6412508086e7a831c02cf3a21aa.tar.gz
https: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36195 Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'lib/https.js')
-rw-r--r--lib/https.js33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/https.js b/lib/https.js
index e1f0936b63..a7fcf06a95 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -22,9 +22,16 @@
'use strict';
const {
+ ArrayPrototypeIndexOf,
+ ArrayPrototypePush,
+ ArrayPrototypeShift,
+ ArrayPrototypeSplice,
+ ArrayPrototypeUnshift,
+ FunctionPrototypeCall,
+ JSONStringify,
ObjectAssign,
ObjectSetPrototypeOf,
- JSONStringify,
+ ReflectConstruct,
} = primordials;
require('internal/util').assertCrypto();
@@ -64,7 +71,7 @@ function Server(opts, requestListener) {
this[kIncomingMessage] = opts.IncomingMessage || IncomingMessage;
this[kServerResponse] = opts.ServerResponse || ServerResponse;
- tls.Server.call(this, opts, _connectionListener);
+ FunctionPrototypeCall(tls.Server, this, opts, _connectionListener);
this.httpAllowHalfOpen = false;
@@ -150,7 +157,7 @@ function Agent(options) {
if (!(this instanceof Agent))
return new Agent(options);
- HttpAgent.call(this, options);
+ FunctionPrototypeCall(HttpAgent, this, options);
this.defaultPort = 443;
this.protocol = 'https:';
this.maxCachedSessions = this.options.maxCachedSessions;
@@ -167,7 +174,7 @@ ObjectSetPrototypeOf(Agent, HttpAgent);
Agent.prototype.createConnection = createConnection;
Agent.prototype.getName = function getName(options) {
- let name = HttpAgent.prototype.getName.call(this, options);
+ let name = FunctionPrototypeCall(HttpAgent.prototype.getName, this, options);
name += ':';
if (options.ca)
@@ -269,21 +276,21 @@ Agent.prototype._cacheSession = function _cacheSession(key, session) {
// Put new entry
if (this._sessionCache.list.length >= this.maxCachedSessions) {
- const oldKey = this._sessionCache.list.shift();
+ const oldKey = ArrayPrototypeShift(this._sessionCache.list);
debug('evicting %j', oldKey);
delete this._sessionCache.map[oldKey];
}
- this._sessionCache.list.push(key);
+ ArrayPrototypePush(this._sessionCache.list, key);
this._sessionCache.map[key] = session;
};
Agent.prototype._evictSession = function _evictSession(key) {
- const index = this._sessionCache.list.indexOf(key);
+ const index = ArrayPrototypeIndexOf(this._sessionCache.list, key);
if (index === -1)
return;
- this._sessionCache.list.splice(index, 1);
+ ArrayPrototypeSplice(this._sessionCache.list, index, 1);
delete this._sessionCache.map[key];
};
@@ -294,7 +301,7 @@ function request(...args) {
let options = {};
if (typeof args[0] === 'string') {
- const urlStr = args.shift();
+ const urlStr = ArrayPrototypeShift(args);
try {
options = urlToOptions(new URL(urlStr));
} catch (err) {
@@ -313,17 +320,17 @@ function request(...args) {
} else if (args[0] && args[0][searchParamsSymbol] &&
args[0][searchParamsSymbol][searchParamsSymbol]) {
// url.URL instance
- options = urlToOptions(args.shift());
+ options = urlToOptions(ArrayPrototypeShift(args));
}
if (args[0] && typeof args[0] !== 'function') {
- ObjectAssign(options, args.shift());
+ ObjectAssign(options, ArrayPrototypeShift(args));
}
options._defaultAgent = module.exports.globalAgent;
- args.unshift(options);
+ ArrayPrototypeUnshift(args, options);
- return new ClientRequest(...args);
+ return ReflectConstruct(ClientRequest, args);
}
function get(input, options, cb) {