summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeth Griggs <bgriggs@redhat.com>2020-12-17 15:10:18 +0000
committerBeth Griggs <bgriggs@redhat.com>2020-12-17 18:34:26 +0000
commit4264d9aa67d1237d05c70f610637dd8bd85f13c3 (patch)
tree89bb8b6a5a44fc298bcad582f9527af79ce45bef
parentf9f01b9a47209ef497e9a23b7bc6acf6fc34160b (diff)
downloadnode-new-4264d9aa67d1237d05c70f610637dd8bd85f13c3.tar.gz
Revert "http: lazy create IncomingMessage.headers"
This reverts commit b58725c4c014ed24ed89e5452993da486df1601b. Fixes: https://github.com/nodejs/node/issues/36550 PR-URL: https://github.com/nodejs/node/pull/36553 Refs: https://github.com/nodejs/node/pull/35281 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
-rw-r--r--lib/_http_incoming.js62
1 files changed, 6 insertions, 56 deletions
diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js
index 05359b9f48..a33d75c3e7 100644
--- a/lib/_http_incoming.js
+++ b/lib/_http_incoming.js
@@ -24,16 +24,10 @@
const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
- Symbol
} = primordials;
const Stream = require('stream');
-const kHeaders = Symbol('kHeaders');
-const kHeadersCount = Symbol('kHeadersCount');
-const kTrailers = Symbol('kTrailers');
-const kTrailersCount = Symbol('kTrailersCount');
-
function readStart(socket) {
if (socket && !socket._paused && socket.readable)
socket.resume();
@@ -64,11 +58,9 @@ function IncomingMessage(socket) {
this.httpVersionMinor = null;
this.httpVersion = null;
this.complete = false;
- this[kHeaders] = null;
- this[kHeadersCount] = 0;
+ this.headers = {};
this.rawHeaders = [];
- this[kTrailers] = null;
- this[kTrailersCount] = 0;
+ this.trailers = {};
this.rawTrailers = [];
this.aborted = false;
@@ -101,44 +93,6 @@ ObjectDefineProperty(IncomingMessage.prototype, 'connection', {
}
});
-ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
- get: function() {
- if (!this[kHeaders]) {
- this[kHeaders] = {};
-
- const src = this.rawHeaders;
- const dst = this[kHeaders];
-
- for (let n = 0; n < this[kHeadersCount]; n += 2) {
- this._addHeaderLine(src[n + 0], src[n + 1], dst);
- }
- }
- return this[kHeaders];
- },
- set: function(val) {
- this[kHeaders] = val;
- }
-});
-
-ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
- get: function() {
- if (!this[kTrailers]) {
- this[kTrailers] = {};
-
- const src = this.rawTrailers;
- const dst = this[kTrailers];
-
- for (let n = 0; n < this[kTrailersCount]; n += 2) {
- this._addHeaderLine(src[n + 0], src[n + 1], dst);
- }
- }
- return this[kTrailers];
- },
- set: function(val) {
- this[kTrailers] = val;
- }
-});
-
IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
if (callback)
this.on('timeout', callback);
@@ -177,18 +131,14 @@ function _addHeaderLines(headers, n) {
let dest;
if (this.complete) {
this.rawTrailers = headers;
- this[kTrailersCount] = n;
- dest = this[kTrailers];
+ dest = this.trailers;
} else {
this.rawHeaders = headers;
- this[kHeadersCount] = n;
- dest = this[kHeaders];
+ dest = this.headers;
}
- if (dest) {
- for (let i = 0; i < n; i += 2) {
- this._addHeaderLine(headers[i], headers[i + 1], dest);
- }
+ for (let i = 0; i < n; i += 2) {
+ this._addHeaderLine(headers[i], headers[i + 1], dest);
}
}
}