From 8ba2cf9c51b6ab40ed1ccbc7c3d161c3cd25e80c Mon Sep 17 00:00:00 2001 From: vitkarpov Date: Sun, 16 Oct 2016 15:47:07 +0300 Subject: [PATCH] http: define all used properties in constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding all used properties in the constructor makes the hidden class stable and heap snapshots more verbose. Refs: https://github.com/nodejs/node/issues/8912 PR-URL: https://github.com/nodejs/node/pull/9116 Reviewed-By: Brian White Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso --- lib/_http_client.js | 16 ++++++++++------ lib/_http_server.js | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index b52d3caf63f92c..97fdf16cc875b1 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -172,6 +172,14 @@ function ClientRequest(options, cb) { self._renderHeaders()); } + this._ended = false; + this.res = null; + this.aborted = undefined; + this.timeoutCb = null; + this.upgradeOrConnect = false; + this.parser = null; + this.maxHeadersCount = null; + var called = false; if (self.socketPath) { self._last = true; @@ -239,16 +247,12 @@ function ClientRequest(options, cb) { self._flush(); self = null; }); - - this._ended = false; } util.inherits(ClientRequest, OutgoingMessage); exports.ClientRequest = ClientRequest; -ClientRequest.prototype.aborted = undefined; - ClientRequest.prototype._finish = function _finish() { DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); LTTNG_HTTP_CLIENT_REQUEST(this, this.connection); @@ -262,7 +266,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() { }; ClientRequest.prototype.abort = function abort() { - if (this.aborted === undefined) { + if (!this.aborted) { process.nextTick(emitAbortNT, this); } // Mark as aborting so we can avoid sending queued request data @@ -491,7 +495,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) { if (res.statusCode === 100) { // restart the parser, as this is a continue message. - delete req.res; // Clear res so that we don't hit double-responses. + req.res = null; // Clear res so that we don't hit double-responses. req.emit('continue'); return true; } diff --git a/lib/_http_server.js b/lib/_http_server.js index 21113fc37a9f5b..bd726f83e3e638 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -248,6 +248,7 @@ function Server(requestListener) { this.timeout = 2 * 60 * 1000; this._pendingResponseData = 0; + this.maxHeadersCount = null; } util.inherits(Server, net.Server);