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 BridgeAR committed Jan 3, 2020
1 parent a6c2502 commit 4a54f30
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 @@ -193,7 +193,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 @@ -210,7 +210,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 @@ -232,7 +232,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 @@ -297,7 +297,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 @@ -468,7 +468,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 @@ -571,7 +571,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 @@ -676,8 +676,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
process.nextTick(connectionCorkNT, msg.socket);
}

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 @@ -711,11 +712,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 @@ -839,11 +840,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 @@ -870,7 +870,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 4a54f30

Please sign in to comment.