This section of the README: https://github.com/nodejitsu/node-http-proxy#modify-response
It suggests that you should use body = Buffer.concat([body, data]); for every chunk received. This causes performance issues for large requests, since the Buffer.concat unnecessarily creates a new copy of the Buffer on every chunk.
The NodeJS docs suggest a different approach: pushing each chunk to a mutable array, with only one Buffer.concat in the "end" event: https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/#request-body
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
});
Happy to submit a PR
This section of the README: https://github.com/nodejitsu/node-http-proxy#modify-response
It suggests that you should use
body = Buffer.concat([body, data]);for every chunk received. This causes performance issues for large requests, since theBuffer.concatunnecessarily creates a new copy of the Buffer on every chunk.The NodeJS docs suggest a different approach: pushing each chunk to a mutable array, with only one
Buffer.concatin the "end" event: https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/#request-bodyHappy to submit a PR