Skip to content

Commit

Permalink
http: reuse existing headers array for raw values
Browse files Browse the repository at this point in the history
PR-URL: #6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
mscdex authored and evanlucas committed Jan 4, 2017
1 parent 064607b commit b094b49
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/_http_incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,17 @@ IncomingMessage.prototype.destroy = function destroy(error) {
IncomingMessage.prototype._addHeaderLines = _addHeaderLines;
function _addHeaderLines(headers, n) {
if (headers && headers.length) {
var raw, dest;
var dest;
if (this.complete) {
raw = this.rawTrailers;
this.rawTrailers = headers;
dest = this.trailers;
} else {
raw = this.rawHeaders;
this.rawHeaders = headers;
dest = this.headers;
}

for (var i = 0; i < n; i += 2) {
var k = headers[i];
var v = headers[i + 1];
raw.push(k);
raw.push(v);
this._addHeaderLine(k, v, dest);
this._addHeaderLine(headers[i], headers[i + 1], dest);
}
}
}
Expand Down

0 comments on commit b094b49

Please sign in to comment.