Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: clean up dead code and unused properties #1572

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ function parserOnMessageComplete() {
parser._url = '';
}

if (!stream.upgrade)
// For upgraded connections, also emit this after parser.execute
stream.push(null);
}

if (stream && !parser.incoming._pendings.length) {
// For emit end event
stream.push(null);
}
Expand Down
14 changes: 11 additions & 3 deletions lib/_http_incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ function IncomingMessage(socket) {

this.readable = true;

this._pendings = [];
this._pendingIndex = 0;
this.upgrade = null;

// request (server) only
Expand All @@ -49,7 +47,7 @@ function IncomingMessage(socket) {
// response (client) only
this.statusCode = null;
this.statusMessage = null;
this.client = this.socket;
this._client = socket; // deprecated

// flag for backwards compatibility grossness.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we deprecate this property than delete it outright.

this._consuming = false;
Expand All @@ -63,6 +61,16 @@ util.inherits(IncomingMessage, Stream.Readable);

exports.IncomingMessage = IncomingMessage;

Object.defineProperty(IncomingMessage.prototype, 'client', {
configurable: true,
enumerable: true,
get: util.deprecate(function() {
return this._client;
}, 'client is deprecated, use socket or connection instead'),
set: util.deprecate(function(val) {
this._client = val;
}, 'client is deprecated, use socket or connection instead')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just saw this. We should use set to change this.client to whatever the passed value is, while not affecting socket.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(As written this changes behavior – previously setting .client would not affect .socket.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, so it should initially be set to this.socket then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, if the setter is changing this.client, wouldn't we have to change the underlying property name (e.g. to something like this._client) otherwise it would lead to some kind of loop (setting this.client inside a this.client setter)?

});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might still want to support set here also if this is not semver-major

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the setter do? Throw a deprecation error? Set this.socket? Set this.client again? Something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would set this.socket. Could also throw a dep error I suppose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, this will break if anyone is trying to do delete req.client for whatever reason..


IncomingMessage.prototype.setTimeout = function(msecs, callback) {
if (callback)
Expand Down
1 change: 0 additions & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function OutgoingMessage() {
this._trailer = '';

this.finished = false;
this._hangupClose = false;
this._headerSent = false;

this.socket = null;
Expand Down