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

Currently mandatory use of "Content-Type": "application/json" header #13

Closed
HeberLZ opened this issue May 4, 2014 · 7 comments
Closed

Comments

@HeberLZ
Copy link

HeberLZ commented May 4, 2014

In the past, this module used to parse json data no matter the Content-Type header was set or not, but since the inclusion of the type-is module, it has changed and now even if the data sent from the client is in json format, it won't parse it unless the Content-Type header is set to application/json.

Is this the way to use this module from now on or is this something intended to be changed in the future?

Cheers!

@Fishrock123
Copy link
Contributor

If you want it to parse json, you must properly send it json. Likewise with urlencoded.
[see index.js]

@dougwilson
Copy link
Contributor

Is this the way to use this module from now on or is this something intended to be changed in the future?

It is the way to use this module from now on, yes.

What content-type are you sending your JSON as, if I may ask?

@HeberLZ
Copy link
Author

HeberLZ commented May 4, 2014

I was not setting up the Content-Type header at all, but now i am doing it the correct way. The issue ocurred during the migration of an express project from 3.x to 4.0.

Thanks for the quick response!

@dougwilson
Copy link
Contributor

No problem.

@diosney
Copy link

diosney commented May 10, 2014

Hi, just stumbled upon this issue.

This new behavior to only parse if the Content-type === 'application/json' is very undesired and counterproducent, since one can send a properly formatted JSON with a different and valid JSON-like content type, like application/vnd.api+json, as in my case (I'm sure there are many other use cases for this).

Any chances that in the very near future automatic detection/parsing (or even providing a custom Content-type to bodyParser options) will be added to json-like bodies/content-types?

Thanks

@dougwilson
Copy link
Contributor

@diosney can you file this feature request as a new issue instead of re-using an issue that is different from what you are asking?

@diosney
Copy link

diosney commented May 10, 2014

Done! #15.

@expressjs expressjs locked and limited conversation to collaborators Jul 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants