You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am invoking a GET endpoint with the following headers and an empty body:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:3001
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
I have defined the bodyparse.json() middleware, and after it, the body.req gets changed from null to an empty object...Why is body-parser replacing the request object, if the content type is not json? Shouldnt the bodyparse not do anything at all given is not the appropiate content type?
Is this a deffect, or is as designed?
Thanks.
The text was updated successfully, but these errors were encountered:
Hi! Yes, the behavior you describe is by design, for better or for worse. The behavior has been changed, to be inline with what you expect, in the 2.0 branch (https://github.com/expressjs/body-parser/tree/2.x). You will have to wait for the 2.0 release (subscribe to PR #66 for updates), just add the following to your package.json: "body-parser": "expressjs/body-parser#2.x", or work-around this (you can use the type-is module's hasBody method to detect if there was really a body or not).
I am invoking a GET endpoint with the following headers and an empty body:
I have defined the
bodyparse.json()
middleware, and after it, the body.req gets changed from null to an empty object...Why is body-parser replacing the request object, if the content type is not json? Shouldnt the bodyparse not do anything at all given is not the appropiate content type?Is this a deffect, or is as designed?
Thanks.
The text was updated successfully, but these errors were encountered: