Skip to content

Commit

Permalink
http: defines all the fields in the constructor
Browse files Browse the repository at this point in the history
res and abort fields are now defined in the constructor and not suddenly appear during the runtime. This makes hidden class stable and the heap snapshot more verbose.

Ref: nodejs#8912
PR-URL: nodejs#9116
  • Loading branch information
vitkarpov committed Jan 10, 2017
1 parent 41567ee commit cc62b20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,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;
Expand Down Expand Up @@ -202,16 +210,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);
Expand All @@ -225,7 +229,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
Expand Down Expand Up @@ -454,7 +458,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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function Server(requestListener) {
this.timeout = 2 * 60 * 1000;

this._pendingResponseData = 0;
this.maxHeadersCount = null;
}
util.inherits(Server, net.Server);

Expand Down

0 comments on commit cc62b20

Please sign in to comment.