Skip to content

Commit f2ad68f

Browse files
committed
http: fix deprecation of client property
Reason: breaks a feature in the request module
1 parent 5d83401 commit f2ad68f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/_http_incoming.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ function readStop(socket) {
1515
}
1616
exports.readStop = readStop;
1717

18+
const deprecatedClientProperty = {
19+
configurable: true,
20+
enumerable: true,
21+
get: util.deprecate(function() {
22+
return this.socket;
23+
}, 'http.IncomingMessage.client is deprecated, use .socket instead'),
24+
set: util.deprecate(function(val) {
25+
this.socket = val;
26+
}, 'http.IncomingMessage.client is deprecated, use .socket instead')
27+
};
1828

1929
/* Abstract base class for ServerRequest and ClientResponse. */
2030
function IncomingMessage(socket) {
@@ -47,7 +57,7 @@ function IncomingMessage(socket) {
4757
// response (client) only
4858
this.statusCode = null;
4959
this.statusMessage = null;
50-
this._client = socket; // deprecated
60+
Object.defineProperty(this, 'client', deprecatedClientProperty);
5161

5262
// flag for backwards compatibility grossness.
5363
this._consuming = false;
@@ -61,16 +71,6 @@ util.inherits(IncomingMessage, Stream.Readable);
6171

6272
exports.IncomingMessage = IncomingMessage;
6373

64-
Object.defineProperty(IncomingMessage.prototype, 'client', {
65-
configurable: true,
66-
enumerable: true,
67-
get: util.deprecate(function() {
68-
return this._client;
69-
}, 'client is deprecated, use socket or connection instead'),
70-
set: util.deprecate(function(val) {
71-
this._client = val;
72-
}, 'client is deprecated, use socket or connection instead')
73-
});
7474

7575
IncomingMessage.prototype.setTimeout = function(msecs, callback) {
7676
if (callback)

0 commit comments

Comments
 (0)