Should content-type default to 'application/x-www-form-urlencoded' for POST requests? #65

wants to merge 1 commit into


None yet
2 participants

Here's the backstory: I was trying to use request to make a POST request to a server running express. I kept on getting 500s, but it would work when I used curl. After four hours of trying to figure out wtf is wrong, I find out the server is using express.bodyParser and assuming req.body would exist, however the bodyParser middleware only populates body on POST and only if the application/x-www-form-urlencoded content-type is set (which curl sets automatically when you POST).

So, this patch sets the content-type to be application/x-www-form-urlencoded if the user hasn't already set one. It's not perfect, because it detects if it's set only by the one particular capitalization scheme, but it is consist with the rest of the code in that way.

There's a bug in here, options.method might not be set by the time I try to uppercase it. I'm gonna self-close this pull request.

aikar commented Sep 2, 2011

Can this be fixed/added?

This problem bit me yesterday... really would be nice if it was defaulted for

It should be reopened as an issue, I closed it because my solution was not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment