Permalink
Browse files

node-http-proxy/http-proxy.js: fix memory leak

Do not keep a reference of the req object through the
req.headers object. Create a copy of the headers object instead.
  • Loading branch information...
1 parent f223ce8 commit 2069a4c88f9fcde85896974182618e468048a6c5 @booo committed May 21, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/node-http-proxy/http-proxy.js
@@ -214,7 +214,15 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
outgoing.agent = this.target.agent;
outgoing.method = req.method;
outgoing.path = req.url;
- outgoing.headers = req.headers;
+ outgoing.headers = {};
+
+ for (var attr in req.headers) {
+ if(req.headers.hasOwnProperty(attr)) {
+ outgoing.headers[attr] = req.headers[attr];
+ }
+ }
+
+
//
// Open new HTTP request to internal resource with will act

0 comments on commit 2069a4c

Please sign in to comment.