Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8d7b241

Browse filesBrowse files
mscdexevanlucas
authored andcommitted
http: misc cleanup and minor optimizations
PR-URL: #6533 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 42e01d6 commit 8d7b241
Copy full SHA for 8d7b241

File tree

Expand file treeCollapse file tree

3 files changed

+8
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-10
lines changed
Open diff view settings
Collapse file

‎lib/_http_common.js‎

Copy file name to clipboardExpand all lines: lib/_http_common.js
-1Lines changed: 0 additions & 1 deletion
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;
Collapse file

‎lib/_http_outgoing.js‎

Copy file name to clipboardExpand all lines: lib/_http_outgoing.js
+3-5Lines changed: 3 additions & 5 deletions
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

Collapse file

‎lib/_http_server.js‎

Copy file name to clipboardExpand all lines: lib/_http_server.js
+5-4Lines changed: 5 additions & 4 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.