summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexahdp <alexahdp@gmail.com>2019-11-06 14:03:16 +0300
committerGireesh Punathil <gpunathi@in.ibm.com>2019-11-12 09:45:09 +0000
commit73780e33e3424c040f42eed7ac3999cdf36bbaa4 (patch)
tree2d61950c3063123e571108e82e6419ae42b281de
parentc396f87efcb4f5f83592943b11e328e9106e286b (diff)
downloadandroid-node-v8-73780e33e3424c040f42eed7ac3999cdf36bbaa4.tar.gz
android-node-v8-73780e33e3424c040f42eed7ac3999cdf36bbaa4.tar.bz2
android-node-v8-73780e33e3424c040f42eed7ac3999cdf36bbaa4.zip
net: replaced vars to lets and consts
PR-URL: https://github.com/nodejs/node/pull/30287 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
-rw-r--r--lib/_http_client.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js
index fcf1cf90fd..30a6366f35 100644
--- a/lib/_http_client.js
+++ b/lib/_http_client.js
@@ -110,7 +110,7 @@ function ClientRequest(input, options, cb) {
options = Object.assign(input || {}, options);
}
- var agent = options.agent;
+ let agent = options.agent;
const defaultAgent = options._defaultAgent || Agent.globalAgent;
if (agent === false) {
agent = new defaultAgent.constructor();
@@ -128,11 +128,11 @@ function ClientRequest(input, options, cb) {
this.agent = agent;
const protocol = options.protocol || defaultAgent.protocol;
- var expectedProtocol = defaultAgent.protocol;
+ let expectedProtocol = defaultAgent.protocol;
if (this.agent && this.agent.protocol)
expectedProtocol = this.agent.protocol;
- var path;
+ let path;
if (options.path) {
path = String(options.path);
if (INVALID_PATH_REGEX.test(path))
@@ -157,7 +157,7 @@ function ClientRequest(input, options, cb) {
if (options.timeout !== undefined)
this.timeout = getTimerDuration(options.timeout, 'timeout');
- var method = options.method;
+ let method = options.method;
const methodIsString = (typeof method === 'string');
if (method !== null && method !== undefined && !methodIsString) {
throw new ERR_INVALID_ARG_TYPE('method', 'string', method);
@@ -197,7 +197,7 @@ function ClientRequest(input, options, cb) {
this.maxHeadersCount = null;
this.reusedSocket = false;
- var called = false;
+ let called = false;
if (this.agent) {
// If there is an agent we should default to Connection:keep-alive,
@@ -216,20 +216,20 @@ function ClientRequest(input, options, cb) {
const headersArray = Array.isArray(options.headers);
if (!headersArray) {
if (options.headers) {
- var keys = Object.keys(options.headers);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
+ const keys = Object.keys(options.headers);
+ for (let i = 0; i < keys.length; i++) {
+ const key = keys[i];
this.setHeader(key, options.headers[key]);
}
}
if (host && !this.getHeader('host') && setHost) {
- var hostHeader = host;
+ let hostHeader = host;
// For the Host header, ensure that IPv6 addresses are enclosed
// in square brackets, as defined by URI formatting
// https://tools.ietf.org/html/rfc3986#section-3.2.2
- var posColon = hostHeader.indexOf(':');
+ const posColon = hostHeader.indexOf(':');
if (posColon !== -1 &&
hostHeader.includes(':', posColon + 1) &&
hostHeader.charCodeAt(0) !== 91/* '[' */) {
@@ -461,8 +461,8 @@ function socketOnData(d) {
req.emit('error', ret);
} else if (parser.incoming && parser.incoming.upgrade) {
// Upgrade (if status code 101) or CONNECT
- var bytesParsed = ret;
- var res = parser.incoming;
+ const bytesParsed = ret;
+ const res = parser.incoming;
req.res = res;
socket.removeListener('data', socketOnData);
@@ -475,9 +475,9 @@ function socketOnData(d) {
parser.finish();
freeParser(parser, req, socket);
- var bodyHead = d.slice(bytesParsed, d.length);
+ const bodyHead = d.slice(bytesParsed, d.length);
- var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
+ const eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
if (req.listenerCount(eventName) > 0) {
req.upgradeOrConnect = true;