Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: rename var to let and const #30279

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ function writeHead(statusCode, reason, obj) {
}
this.statusCode = statusCode;

var headers;
let headers;
if (this[kOutHeaders]) {
// Slow-case: when progressive API and header fields are passed.
var k;
let k;
if (obj) {
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
const keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
k = keys[i];
if (k) this.setHeader(k, obj[k]);
}
Expand Down Expand Up @@ -483,7 +483,7 @@ function socketOnClose(socket, state) {

function abortIncoming(incoming) {
while (incoming.length) {
var req = incoming.shift();
const req = incoming.shift();
req.aborted = true;
req.emit('aborted');
req.emit('close');
Expand Down Expand Up @@ -573,8 +573,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
socketOnError.call(socket, ret);
} else if (parser.incoming && parser.incoming.upgrade) {
// Upgrade or CONNECT
var bytesParsed = ret;
var req = parser.incoming;
const req = parser.incoming;
debug('SERVER upgrade or connect', req.method);

if (!d)
Expand All @@ -591,10 +590,10 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
freeParser(parser, req, socket);
parser = null;

var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
const eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
if (eventName === 'upgrade' || server.listenerCount(eventName) > 0) {
debug('SERVER have listener for %s', eventName);
var bodyHead = d.slice(bytesParsed, d.length);
const bodyHead = d.slice(ret, d.length);

socket.readableFlowing = null;
server.emit(eventName, req, socket, bodyHead);
Expand Down Expand Up @@ -656,7 +655,7 @@ function resOnFinish(req, res, socket, state, server) {
}
} else {
// Start sending the next message
var m = state.outgoing.shift();
const m = state.outgoing.shift();
if (m) {
m.assignSocket(socket);
}
Expand Down Expand Up @@ -693,7 +692,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
// so that we don't become overwhelmed by a flood of
// pipelined requests that may never be resolved.
if (!socket._paused) {
var ws = socket._writableState;
const ws = socket._writableState;
if (ws.needDrain || state.outgoingData >= socket.writableHighWaterMark) {
socket._paused = true;
// We also need to pause the parser, but don't do that until after
Expand Down