Skip to content

Commit

Permalink
fix 'Modify Response' readme section to avoid unnecessary array copyi…
Browse files Browse the repository at this point in the history
…ng (#1300)
  • Loading branch information
nilligan authored and indexzero committed Aug 22, 2019
1 parent 244303b commit d056241
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -501,12 +501,12 @@ data.
selfHandleResponse : true
};
proxy.on('proxyRes', function (proxyRes, req, res) {
var body = new Buffer('');
proxyRes.on('data', function (data) {
body = Buffer.concat([body, data]);
var body = [];
proxyRes.on('data', function (chunk) {
body.push(chunk);
});
proxyRes.on('end', function () {
body = body.toString();
body = Buffer.concat(body).toString();
console.log("res from proxied server:", body);
res.end("my response to cli");
});
Expand Down

0 comments on commit d056241

Please sign in to comment.