http: define all used properties in constructors

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 <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
vitkarpov 2016-10-16 15:47:07 +03:00 committed by Brian White
parent 3f61521087
commit a2ea1344ea
No known key found for this signature in database
GPG Key ID: 606D7358F94DA209
2 changed files with 11 additions and 6 deletions

View File

@ -135,6 +135,14 @@ function ClientRequest(options, cb) {
self._renderHeaders()); 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; var called = false;
if (self.socketPath) { if (self.socketPath) {
self._last = true; self._last = true;
@ -202,16 +210,12 @@ function ClientRequest(options, cb) {
self._flush(); self._flush();
self = null; self = null;
}); });
this._ended = false;
} }
util.inherits(ClientRequest, OutgoingMessage); util.inherits(ClientRequest, OutgoingMessage);
exports.ClientRequest = ClientRequest; exports.ClientRequest = ClientRequest;
ClientRequest.prototype.aborted = undefined;
ClientRequest.prototype._finish = function _finish() { ClientRequest.prototype._finish = function _finish() {
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
LTTNG_HTTP_CLIENT_REQUEST(this, this.connection); LTTNG_HTTP_CLIENT_REQUEST(this, this.connection);
@ -225,7 +229,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {
}; };
ClientRequest.prototype.abort = function abort() { ClientRequest.prototype.abort = function abort() {
if (this.aborted === undefined) { if (!this.aborted) {
process.nextTick(emitAbortNT, this); process.nextTick(emitAbortNT, this);
} }
// Mark as aborting so we can avoid sending queued request data // Mark as aborting so we can avoid sending queued request data
@ -454,7 +458,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
if (res.statusCode === 100) { if (res.statusCode === 100) {
// restart the parser, as this is a continue message. // 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'); req.emit('continue');
return true; return true;
} }

View File

@ -248,6 +248,7 @@ function Server(requestListener) {
this.timeout = 2 * 60 * 1000; this.timeout = 2 * 60 * 1000;
this._pendingResponseData = 0; this._pendingResponseData = 0;
this.maxHeadersCount = null;
} }
util.inherits(Server, net.Server); util.inherits(Server, net.Server);