@@ -15,6 +15,16 @@ function readStop(socket) {
15
15
}
16
16
exports . readStop = readStop ;
17
17
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
+ } ;
18
28
19
29
/* Abstract base class for ServerRequest and ClientResponse. */
20
30
function IncomingMessage ( socket ) {
@@ -47,7 +57,7 @@ function IncomingMessage(socket) {
47
57
// response (client) only
48
58
this . statusCode = null ;
49
59
this . statusMessage = null ;
50
- this . _client = socket ; // deprecated
60
+ Object . defineProperty ( this , 'client' , deprecatedClientProperty ) ;
51
61
52
62
// flag for backwards compatibility grossness.
53
63
this . _consuming = false ;
@@ -61,16 +71,6 @@ util.inherits(IncomingMessage, Stream.Readable);
61
71
62
72
exports . IncomingMessage = IncomingMessage ;
63
73
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
- } ) ;
74
74
75
75
IncomingMessage . prototype . setTimeout = function ( msecs , callback ) {
76
76
if ( callback )
0 commit comments