Permalink
Browse files

http: reuse existing headers array for raw values

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...
1 parent 064607b commit b094b49659f82dd2a23f4460d5dea6a675f327b9 @mscdex mscdex committed with evanlucas Dec 18, 2016
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/_http_incoming.js
View
@@ -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);
}
}
}

0 comments on commit b094b49

Please sign in to comment.