Skip to content

Commit c199570

Browse files
alexahdptargos
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 70cf4d2 commit c199570

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/_http_client.js

+14-14
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);
@@ -196,7 +196,7 @@ function ClientRequest(input, options, cb) {
196196
this.parser = null;
197197
this.maxHeadersCount = null;
198198

199-
var called = false;
199+
let called = false;
200200

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

225225
if (host && !this.getHeader('host') && setHost) {
226-
var hostHeader = host;
226+
let hostHeader = host;
227227

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

470470
socket.removeListener('data', socketOnData);
@@ -473,9 +473,9 @@ function socketOnData(d) {
473473
parser.finish();
474474
freeParser(parser, req, socket);
475475

476-
var bodyHead = d.slice(bytesParsed, d.length);
476+
const bodyHead = d.slice(bytesParsed, d.length);
477477

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

0 commit comments

Comments
 (0)