Skip to content

Commit 8ba2cf9

Browse files
vitkarpovitaloacasas
authored andcommitted
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: #8912 PR-URL: #9116 Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 4323c80 commit 8ba2cf9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/_http_client.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ function ClientRequest(options, cb) {
172172
self._renderHeaders());
173173
}
174174

175+
this._ended = false;
176+
this.res = null;
177+
this.aborted = undefined;
178+
this.timeoutCb = null;
179+
this.upgradeOrConnect = false;
180+
this.parser = null;
181+
this.maxHeadersCount = null;
182+
175183
var called = false;
176184
if (self.socketPath) {
177185
self._last = true;
@@ -239,16 +247,12 @@ function ClientRequest(options, cb) {
239247
self._flush();
240248
self = null;
241249
});
242-
243-
this._ended = false;
244250
}
245251

246252
util.inherits(ClientRequest, OutgoingMessage);
247253

248254
exports.ClientRequest = ClientRequest;
249255

250-
ClientRequest.prototype.aborted = undefined;
251-
252256
ClientRequest.prototype._finish = function _finish() {
253257
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
254258
LTTNG_HTTP_CLIENT_REQUEST(this, this.connection);
@@ -262,7 +266,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {
262266
};
263267

264268
ClientRequest.prototype.abort = function abort() {
265-
if (this.aborted === undefined) {
269+
if (!this.aborted) {
266270
process.nextTick(emitAbortNT, this);
267271
}
268272
// Mark as aborting so we can avoid sending queued request data
@@ -491,7 +495,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
491495

492496
if (res.statusCode === 100) {
493497
// restart the parser, as this is a continue message.
494-
delete req.res; // Clear res so that we don't hit double-responses.
498+
req.res = null; // Clear res so that we don't hit double-responses.
495499
req.emit('continue');
496500
return true;
497501
}

lib/_http_server.js

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ function Server(requestListener) {
248248
this.timeout = 2 * 60 * 1000;
249249

250250
this._pendingResponseData = 0;
251+
this.maxHeadersCount = null;
251252
}
252253
util.inherits(Server, net.Server);
253254

0 commit comments

Comments
 (0)