Skip to content

Commit 9230fff

Browse files
alexahdpMylesBorins
authored andcommitted
net: replaced vars to lets and consts
PR-URL: #30287 Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent b8aceac commit 9230fff

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/_http_client.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function ClientRequest(input, options, cb) {
110110
options = Object.assign(input || {}, options);
111111
}
112112

113-
var agent = options.agent;
113+
let agent = options.agent;
114114
const defaultAgent = options._defaultAgent || Agent.globalAgent;
115115
if (agent === false) {
116116
agent = new defaultAgent.constructor();
@@ -128,11 +128,11 @@ function ClientRequest(input, options, cb) {
128128
this.agent = agent;
129129

130130
const protocol = options.protocol || defaultAgent.protocol;
131-
var expectedProtocol = defaultAgent.protocol;
131+
let expectedProtocol = defaultAgent.protocol;
132132
if (this.agent && this.agent.protocol)
133133
expectedProtocol = this.agent.protocol;
134134

135-
var path;
135+
let path;
136136
if (options.path) {
137137
path = String(options.path);
138138
if (INVALID_PATH_REGEX.test(path))
@@ -157,7 +157,7 @@ function ClientRequest(input, options, cb) {
157157
if (options.timeout !== undefined)
158158
this.timeout = getTimerDuration(options.timeout, 'timeout');
159159

160-
var method = options.method;
160+
let method = options.method;
161161
const methodIsString = (typeof method === 'string');
162162
if (method !== null && method !== undefined && !methodIsString) {
163163
throw new ERR_INVALID_ARG_TYPE('method', 'string', method);
@@ -197,7 +197,7 @@ function ClientRequest(input, options, cb) {
197197
this.maxHeadersCount = null;
198198
this.reusedSocket = false;
199199

200-
var called = false;
200+
let called = false;
201201

202202
if (this.agent) {
203203
// If there is an agent we should default to Connection:keep-alive,
@@ -216,20 +216,20 @@ function ClientRequest(input, options, cb) {
216216
const headersArray = Array.isArray(options.headers);
217217
if (!headersArray) {
218218
if (options.headers) {
219-
var keys = Object.keys(options.headers);
220-
for (var i = 0; i < keys.length; i++) {
221-
var key = keys[i];
219+
const keys = Object.keys(options.headers);
220+
for (let i = 0; i < keys.length; i++) {
221+
const key = keys[i];
222222
this.setHeader(key, options.headers[key]);
223223
}
224224
}
225225

226226
if (host && !this.getHeader('host') && setHost) {
227-
var hostHeader = host;
227+
let hostHeader = host;
228228

229229
// For the Host header, ensure that IPv6 addresses are enclosed
230230
// in square brackets, as defined by URI formatting
231231
// https://tools.ietf.org/html/rfc3986#section-3.2.2
232-
var posColon = hostHeader.indexOf(':');
232+
const posColon = hostHeader.indexOf(':');
233233
if (posColon !== -1 &&
234234
hostHeader.includes(':', posColon + 1) &&
235235
hostHeader.charCodeAt(0) !== 91/* '[' */) {
@@ -461,8 +461,8 @@ function socketOnData(d) {
461461
req.emit('error', ret);
462462
} else if (parser.incoming && parser.incoming.upgrade) {
463463
// Upgrade (if status code 101) or CONNECT
464-
var bytesParsed = ret;
465-
var res = parser.incoming;
464+
const bytesParsed = ret;
465+
const res = parser.incoming;
466466
req.res = res;
467467

468468
socket.removeListener('data', socketOnData);
@@ -475,9 +475,9 @@ function socketOnData(d) {
475475
parser.finish();
476476
freeParser(parser, req, socket);
477477

478-
var bodyHead = d.slice(bytesParsed, d.length);
478+
const bodyHead = d.slice(bytesParsed, d.length);
479479

480-
var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
480+
const eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
481481
if (req.listenerCount(eventName) > 0) {
482482
req.upgradeOrConnect = true;
483483

0 commit comments

Comments
 (0)