fix 'Modify Response' readme section to avoid unnecessary array copying (#1300)

This commit is contained in:
Nick Gilligan 2019-08-22 00:40:15 -07:00 committed by Charlie Robbins
parent 244303b994
commit d05624167c

View File

@ -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");
});