Skip to content
Closed
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
33 changes: 20 additions & 13 deletions lib/https.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,9 +22,16 @@
'use strict';

const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeShift,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
FunctionPrototypeCall,
JSONStringify,
ObjectAssign,
ObjectSetPrototypeOf,
JSONStringify,
ReflectConstruct,
} = primordials;

require('internal/util').assertCrypto();
Expand DownExpand Up@@ -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;

Expand DownExpand Up@@ -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;
Expand All@@ -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)
Expand DownExpand Up@@ -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];
};

Expand All@@ -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) {
Expand All@@ -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) {
Expand Down