Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Issues
  • #1277
Closed
Open
Issue created Jun 22, 2018 by Administrator@rootContributor

"Modify Response" example code has problems

Created by: nilligan

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

Assignee
Assign to
Time tracking