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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
mscdex authored and evanlucas committed Jan 3, 2017
1 parent 8db7cd8 commit 42e01d6
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 42e01d6

Please sign in to comment.