Skip to content

Commit 06d8606

Browse files
authoredJun 3, 2022
lib: use null-prototype objects for property descriptors
Refs: nodejs#42921 PR-URL: nodejs#43270 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent 218664f commit 06d8606

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+446
-85
lines changed
 

‎lib/_http_incoming.js

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ ObjectSetPrototypeOf(IncomingMessage.prototype, Readable.prototype);
9898
ObjectSetPrototypeOf(IncomingMessage, Readable);
9999

100100
ObjectDefineProperty(IncomingMessage.prototype, 'connection', {
101+
__proto__: null,
101102
get: function() {
102103
return this.socket;
103104
},
@@ -107,6 +108,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'connection', {
107108
});
108109

109110
ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
111+
__proto__: null,
110112
get: function() {
111113
if (!this[kHeaders]) {
112114
this[kHeaders] = {};
@@ -126,6 +128,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
126128
});
127129

128130
ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
131+
__proto__: null,
129132
get: function() {
130133
if (!this[kHeadersDistinct]) {
131134
this[kHeadersDistinct] = {};
@@ -145,6 +148,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
145148
});
146149

147150
ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
151+
__proto__: null,
148152
get: function() {
149153
if (!this[kTrailers]) {
150154
this[kTrailers] = {};
@@ -164,6 +168,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
164168
});
165169

166170
ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
171+
__proto__: null,
167172
get: function() {
168173
if (!this[kTrailersDistinct]) {
169174
this[kTrailersDistinct] = {};

‎lib/_http_outgoing.js

+11
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ ObjectSetPrototypeOf(OutgoingMessage.prototype, Stream.prototype);
145145
ObjectSetPrototypeOf(OutgoingMessage, Stream);
146146

147147
ObjectDefineProperty(OutgoingMessage.prototype, 'writableFinished', {
148+
__proto__: null,
148149
get() {
149150
return (
150151
this.finished &&
@@ -155,31 +156,36 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableFinished', {
155156
});
156157

157158
ObjectDefineProperty(OutgoingMessage.prototype, 'writableObjectMode', {
159+
__proto__: null,
158160
get() {
159161
return false;
160162
}
161163
});
162164

163165
ObjectDefineProperty(OutgoingMessage.prototype, 'writableLength', {
166+
__proto__: null,
164167
get() {
165168
return this.outputSize + (this.socket ? this.socket.writableLength : 0);
166169
}
167170
});
168171

169172
ObjectDefineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', {
173+
__proto__: null,
170174
get() {
171175
return this.socket ? this.socket.writableHighWaterMark : HIGH_WATER_MARK;
172176
}
173177
});
174178

175179
ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', {
180+
__proto__: null,
176181
get() {
177182
const corked = this.socket ? this.socket.writableCorked : 0;
178183
return corked + this[kCorked];
179184
}
180185
});
181186

182187
ObjectDefineProperty(OutgoingMessage.prototype, '_headers', {
188+
__proto__: null,
183189
get: internalUtil.deprecate(function() {
184190
return this.getHeaders();
185191
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
@@ -200,6 +206,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', {
200206
});
201207

202208
ObjectDefineProperty(OutgoingMessage.prototype, 'connection', {
209+
__proto__: null,
203210
get: function() {
204211
return this.socket;
205212
},
@@ -209,6 +216,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'connection', {
209216
});
210217

211218
ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', {
219+
__proto__: null,
212220
get: internalUtil.deprecate(function() {
213221
const headers = this[kOutHeaders];
214222
if (headers !== null) {
@@ -731,16 +739,19 @@ OutgoingMessage.prototype._implicitHeader = function _implicitHeader() {
731739
};
732740

733741
ObjectDefineProperty(OutgoingMessage.prototype, 'headersSent', {
742+
__proto__: null,
734743
configurable: true,
735744
enumerable: true,
736745
get: function() { return !!this._header; }
737746
});
738747

739748
ObjectDefineProperty(OutgoingMessage.prototype, 'writableEnded', {
749+
__proto__: null,
740750
get: function() { return this.finished; }
741751
});
742752

743753
ObjectDefineProperty(OutgoingMessage.prototype, 'writableNeedDrain', {
754+
__proto__: null,
744755
get: function() {
745756
return !this.destroyed && !this.finished && this[kNeedDrain];
746757
}

0 commit comments

Comments
 (0)