Skip to content

Commit 1f0fd7b

Browse files
mscdexevanlucas
authored andcommitted
http: misc cleanup and minor optimizations
PR-URL: #6533 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent b094b49 commit 1f0fd7b

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/_http_common.js

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ function freeParser(parser, req, socket) {
198198
parser[kOnExecute] = null;
199199
if (parsers.free(parser) === false)
200200
parser.close();
201-
parser = null;
202201
}
203202
if (req) {
204203
req.parser = null;

lib/_http_outgoing.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ OutgoingMessage.prototype.getHeader = function getHeader(name) {
380380

381381
if (!this._headers) return;
382382

383-
var key = name.toLowerCase();
384-
return this._headers[key];
383+
return this._headers[name.toLowerCase()];
385384
};
386385

387386

@@ -585,7 +584,6 @@ OutgoingMessage.prototype.end = function end(data, encoding, callback) {
585584
if (this.connection && data)
586585
this.connection.cork();
587586

588-
var ret;
589587
if (data) {
590588
// Normal body write.
591589
this.write(data, encoding);
@@ -598,6 +596,7 @@ OutgoingMessage.prototype.end = function end(data, encoding, callback) {
598596
this.emit('finish');
599597
};
600598

599+
var ret;
601600
if (this._hasBody && this.chunkedEncoding) {
602601
ret = this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
603602
} else {
@@ -677,8 +676,7 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) {
677676
var outputCallbacks = this.outputCallbacks;
678677
socket.cork();
679678
for (var i = 0; i < outputLength; i++) {
680-
ret = socket.write(output[i], outputEncodings[i],
681-
outputCallbacks[i]);
679+
ret = socket.write(output[i], outputEncodings[i], outputCallbacks[i]);
682680
}
683681
socket.uncork();
684682

lib/_http_server.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ function ServerResponse(req) {
8888
if (req.method === 'HEAD') this._hasBody = false;
8989

9090
this.sendDate = true;
91+
this._sent100 = false;
92+
this._expect_continue = false;
9193

9294
if (req.httpVersionMajor < 1 || req.httpVersionMinor < 1) {
9395
this.useChunkedEncodingByDefault = chunkExpression.test(req.headers.te);
@@ -195,8 +197,7 @@ function writeHead(statusCode, reason, obj) {
195197
if (common._checkInvalidHeaderChar(this.statusMessage))
196198
throw new Error('Invalid character in statusMessage.');
197199

198-
var statusLine = 'HTTP/1.1 ' + statusCode.toString() + ' ' +
199-
this.statusMessage + CRLF;
200+
var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF;
200201

201202
if (statusCode === 204 || statusCode === 304 ||
202203
(100 <= statusCode && statusCode <= 199)) {
@@ -232,7 +233,7 @@ function Server(requestListener) {
232233
net.Server.call(this, { allowHalfOpen: true });
233234

234235
if (requestListener) {
235-
this.addListener('request', requestListener);
236+
this.on('request', requestListener);
236237
}
237238

238239
/* eslint-disable max-len */
@@ -242,7 +243,7 @@ function Server(requestListener) {
242243
/* eslint-enable max-len */
243244
this.httpAllowHalfOpen = false;
244245

245-
this.addListener('connection', connectionListener);
246+
this.on('connection', connectionListener);
246247

247248
this.timeout = 2 * 60 * 1000;
248249

0 commit comments

Comments
 (0)