nodejitsu/node-http-proxy — pull request #736 by richardkazuomiller (2014-11-12 20:24:23+00:00)
Title: copy headers instead of referencing them so they don't unexpectedly get overwritten

Currently `common.setupOutgoing` uses a reference to the original request headers, which causes `Connection` to be overwritten in some cases, and `Host` to be overwritten when `changeOrigin` is set to `true`. If you use the `proxyReq` to look at the original request and the proxy request you will find that those headers have been modified on the original request object.

I modified one test case that set the request headers to a string because using `utils._extend` on a string doesn't work. As far as I know `req.headers` will always be an object so I think what I did is fine but if there's a reason that was a string, I'll fix it so it checks the type.