Skip to content

Commit

Permalink
http: http_outgoing rename var to let and const
Browse files Browse the repository at this point in the history
PR-URL: #30284
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
telenord authored and targos committed Jan 14, 2020
1 parent b840eb7 commit 725daeb
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', {
const keys = ObjectKeys(val);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const name = keys[i];
headers[name.toLowerCase()] = [name, val[name]];
}
Expand All @@ -184,7 +184,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', {
const keys = ObjectKeys(headers);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const val = headers[key][0];
out[key] = val;
Expand All @@ -201,7 +201,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', {
const keys = ObjectKeys(val);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const header = headers[keys[i]];
if (header)
header[0] = val[keys[i]];
Expand All @@ -223,7 +223,7 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
const keys = ObjectKeys(headersMap);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0, l = keys.length; i < l; i++) {
for (let i = 0, l = keys.length; i < l; i++) {
const key = keys[i];
headers[headersMap[key][0]] = headersMap[key][1];
}
Expand Down Expand Up @@ -288,7 +288,7 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
(encoding === 'utf8' || encoding === 'latin1' || !encoding)) {
data = this._header + data;
} else {
var header = this._header;
const header = this._header;
if (this.outputData.length === 0) {
this.outputData = [{
data: header,
Expand Down Expand Up @@ -459,7 +459,7 @@ function processHeader(self, state, key, value, validate) {
if (value.length < 2 || !isCookieField(key)) {
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < value.length; i++)
for (let i = 0; i < value.length; i++)
storeHeader(self, state, key, value[i], validate);
return;
}
Expand Down Expand Up @@ -562,7 +562,7 @@ OutgoingMessage.prototype.getHeaders = function getHeaders() {
const keys = ObjectKeys(headers);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const val = headers[key][1];
ret[key] = val;
Expand Down Expand Up @@ -667,8 +667,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
process.nextTick(connectionCorkNT, msg, msg.connection);
}

var len, ret;
let ret;
if (msg.chunkedEncoding && chunk.length !== 0) {
let len;
if (typeof chunk === 'string')
len = Buffer.byteLength(chunk, encoding);
else
Expand Down Expand Up @@ -702,11 +703,11 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
this._trailer = '';
const keys = ObjectKeys(headers);
const isArray = ArrayIsArray(headers);
var field, value;
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
for (let i = 0, l = keys.length; i < l; i++) {
let field, value;
const key = keys[i];
if (isArray) {
field = headers[key][0];
value = headers[key][1];
Expand Down Expand Up @@ -823,11 +824,10 @@ OutgoingMessage.prototype._finish = function _finish() {
// to attempt to flush any pending messages out to the socket.
OutgoingMessage.prototype._flush = function _flush() {
const socket = this.socket;
var ret;

if (socket && socket.writable) {
// There might be remaining data in this.output; write it out
ret = this._flushOutput(socket);
const ret = this._flushOutput(socket);

if (this.finished) {
// This is a queue to the server or client to bring in the next this.
Expand All @@ -854,7 +854,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) {
let ret;
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (var i = 0; i < outputLength; i++) {
for (let i = 0; i < outputLength; i++) {
const { data, encoding, callback } = outputData[i];
ret = socket.write(data, encoding, callback);
}
Expand Down

0 comments on commit 725daeb

Please sign in to comment.