Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy headers instead of referencing them so they don't unexpectedly get overwritten #736

Merged
merged 2 commits into from
Nov 12, 2014

Conversation

richardkazuomiller
Copy link
Contributor

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.

function(e) { outgoing[e] = req[e]; }
);
outgoing.method = req.method
outgoing.headers = extend({},req.headers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a space after the empty object passed to extend? Also add a semicolon to the end;

@richardkazuomiller
Copy link
Contributor Author

I've updated my branch - please have a look (^_^)

Also, I admire your team's strict adherence to your style guide. I'm usually much lazier than I should be haha. I did some Googling and found this. Should contributors be following that?

@jcrugzz
Copy link
Contributor

jcrugzz commented Nov 12, 2014

@richardkazuomiller yea essentially, good find! That should just be linked somewhere. @indexzero just hasn't formalized a jscs for it yet.

jcrugzz added a commit that referenced this pull request Nov 12, 2014
copy headers instead of referencing them so they don't unexpectedly get overwritten
@jcrugzz jcrugzz merged commit aba505d into http-party:master Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants