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.
Default content-type header to 'application/x-www-form-urlencoded' fo…
…r post requests.
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.
Can this be fixed/added?
This problem bit me yesterday... really would be nice if it was defaulted for request.post()
It should be reopened as an issue, I closed it because my solution was not ideal.