|
24 | 24 | const { |
25 | 25 | ObjectDefineProperty, |
26 | 26 | ObjectSetPrototypeOf, |
27 | | - Symbol |
28 | 27 | } = primordials; |
29 | 28 |
|
30 | 29 | const Stream = require('stream'); |
31 | 30 |
|
32 | | -const kHeaders = Symbol('kHeaders'); |
33 | | -const kHeadersCount = Symbol('kHeadersCount'); |
34 | | -const kTrailers = Symbol('kTrailers'); |
35 | | -const kTrailersCount = Symbol('kTrailersCount'); |
36 | | - |
37 | 31 | function readStart(socket) { |
38 | 32 | if (socket && !socket._paused && socket.readable) |
39 | 33 | socket.resume(); |
@@ -64,11 +58,9 @@ function IncomingMessage(socket) { |
64 | 58 | this.httpVersionMinor = null; |
65 | 59 | this.httpVersion = null; |
66 | 60 | this.complete = false; |
67 | | - this[kHeaders] = null; |
68 | | - this[kHeadersCount] = 0; |
| 61 | + this.headers = {}; |
69 | 62 | this.rawHeaders = []; |
70 | | - this[kTrailers] = null; |
71 | | - this[kTrailersCount] = 0; |
| 63 | + this.trailers = {}; |
72 | 64 | this.rawTrailers = []; |
73 | 65 |
|
74 | 66 | this.aborted = false; |
@@ -101,44 +93,6 @@ ObjectDefineProperty(IncomingMessage.prototype, 'connection', { |
101 | 93 | } |
102 | 94 | }); |
103 | 95 |
|
104 | | -ObjectDefineProperty(IncomingMessage.prototype, 'headers', { |
105 | | - get: function() { |
106 | | - if (!this[kHeaders]) { |
107 | | - this[kHeaders] = {}; |
108 | | - |
109 | | - const src = this.rawHeaders; |
110 | | - const dst = this[kHeaders]; |
111 | | - |
112 | | - for (let n = 0; n < this[kHeadersCount]; n += 2) { |
113 | | - this._addHeaderLine(src[n + 0], src[n + 1], dst); |
114 | | - } |
115 | | - } |
116 | | - return this[kHeaders]; |
117 | | - }, |
118 | | - set: function(val) { |
119 | | - this[kHeaders] = val; |
120 | | - } |
121 | | -}); |
122 | | - |
123 | | -ObjectDefineProperty(IncomingMessage.prototype, 'trailers', { |
124 | | - get: function() { |
125 | | - if (!this[kTrailers]) { |
126 | | - this[kTrailers] = {}; |
127 | | - |
128 | | - const src = this.rawTrailers; |
129 | | - const dst = this[kTrailers]; |
130 | | - |
131 | | - for (let n = 0; n < this[kTrailersCount]; n += 2) { |
132 | | - this._addHeaderLine(src[n + 0], src[n + 1], dst); |
133 | | - } |
134 | | - } |
135 | | - return this[kTrailers]; |
136 | | - }, |
137 | | - set: function(val) { |
138 | | - this[kTrailers] = val; |
139 | | - } |
140 | | -}); |
141 | | - |
142 | 96 | IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) { |
143 | 97 | if (callback) |
144 | 98 | this.on('timeout', callback); |
@@ -177,18 +131,14 @@ function _addHeaderLines(headers, n) { |
177 | 131 | let dest; |
178 | 132 | if (this.complete) { |
179 | 133 | this.rawTrailers = headers; |
180 | | - this[kTrailersCount] = n; |
181 | | - dest = this[kTrailers]; |
| 134 | + dest = this.trailers; |
182 | 135 | } else { |
183 | 136 | this.rawHeaders = headers; |
184 | | - this[kHeadersCount] = n; |
185 | | - dest = this[kHeaders]; |
| 137 | + dest = this.headers; |
186 | 138 | } |
187 | 139 |
|
188 | | - if (dest) { |
189 | | - for (let i = 0; i < n; i += 2) { |
190 | | - this._addHeaderLine(headers[i], headers[i + 1], dest); |
191 | | - } |
| 140 | + for (let i = 0; i < n; i += 2) { |
| 141 | + this._addHeaderLine(headers[i], headers[i + 1], dest); |
192 | 142 | } |
193 | 143 | } |
194 | 144 | } |
|
0 commit comments