diff options
author | Brian White <mscdex@mscdex.net> | 2016-12-31 16:27:40 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-01-11 12:54:45 -0500 |
commit | 176cdc282366a9bd387dcd76dc4fd967c1a0bf37 (patch) | |
tree | 7aa3689128c8b5e67b3627957576262ab2ff16f0 /lib/_http_server.js | |
parent | 73d94457827f6c2dbef734f40efe5e7812a45f42 (diff) | |
download | android-node-v8-176cdc282366a9bd387dcd76dc4fd967c1a0bf37.tar.gz android-node-v8-176cdc282366a9bd387dcd76dc4fd967c1a0bf37.tar.bz2 android-node-v8-176cdc282366a9bd387dcd76dc4fd967c1a0bf37.zip |
http: misc optimizations and style fixes
PR-URL: https://github.com/nodejs/node/pull/10558
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'lib/_http_server.js')
-rw-r--r-- | lib/_http_server.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/_http_server.js b/lib/_http_server.js index d473fd3281..be55784e7e 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -170,8 +170,8 @@ function writeHead(statusCode, reason, obj) { this.statusMessage = reason; } else { // writeHead(statusCode[, headers]) - this.statusMessage = - this.statusMessage || STATUS_CODES[statusCode] || 'unknown'; + if (!this.statusMessage) + this.statusMessage = STATUS_CODES[statusCode] || 'unknown'; obj = reason; } this.statusCode = statusCode; @@ -514,9 +514,8 @@ 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 needPause = socket._writableState.needDrain || - state.outgoingData >= socket._writableState.highWaterMark; - if (needPause) { + var ws = socket._writableState; + if (ws.needDrain || state.outgoingData >= ws.highWaterMark) { socket._paused = true; // We also need to pause the parser, but don't do that until after // the call to execute, because we may still be processing the last @@ -542,9 +541,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { // When we're finished writing the response, check if this is the last // response, if so destroy the socket. - var finish = - resOnFinish.bind(undefined, req, res, socket, state); - res.on('finish', finish); + res.on('finish', resOnFinish.bind(undefined, req, res, socket, state)); if (req.headers.expect !== undefined && (req.httpVersionMajor === 1 && req.httpVersionMinor === 1)) { |