http: use kEmptyObject

PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
LiviaMedeiros 2022-05-21 17:52:47 +08:00 committed by Antoine du Hamel
parent c52454fdc3
commit a709a7155d
No known key found for this signature in database
GPG Key ID: 21D900FFDB233756
2 changed files with 10 additions and 4 deletions

View File

@ -54,7 +54,10 @@ const {
ERR_OUT_OF_RANGE,
},
} = require('internal/errors');
const { once } = require('internal/util');
const {
kEmptyObject,
once,
} = require('internal/util');
const {
validateNumber,
validateOneOf,
@ -220,7 +223,7 @@ Agent.defaultMaxSockets = Infinity;
Agent.prototype.createConnection = net.createConnection;
// Get the key for a given set of request options
Agent.prototype.getName = function getName(options = {}) {
Agent.prototype.getName = function getName(options = kEmptyObject) {
let name = options.host || 'localhost';
name += ':';

View File

@ -43,7 +43,10 @@ const {
const net = require('net');
const assert = require('internal/assert');
const { once } = require('internal/util');
const {
kEmptyObject,
once,
} = require('internal/util');
const {
_checkIsHttpToken: checkIsHttpToken,
freeParser,
@ -133,7 +136,7 @@ function ClientRequest(input, options, cb) {
if (typeof options === 'function') {
cb = options;
options = input || {};
options = input || kEmptyObject;
} else {
options = ObjectAssign(input || {}, options);
}