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
Hello! I just ran into a bug in another piece of software based on an interesting behavior in body-parser: apigee-127/swagger-tools#533
The problem here is that even if a body parser should not parse (e.g. because the content type does not match), the parser still sets req.body = {}. This led another tool to think that parsing had already occurred, because req.body was defined.
I was wondering if it is possible to not modify the request at all if parsing should not be performed. That is the behavior I would expect.
You can see an example of this behavior in the raw parser here:
The current behavior is documented at the top of the readme as well:
All middlewares will populate the req.body property with the parsed body when the Content-Type request header matches the type option, or an empty object ({}) if there was no body to parse, the Content-Type was not matched, or an error occurred.
Hello! I just ran into a bug in another piece of software based on an interesting behavior in
body-parser
:apigee-127/swagger-tools#533
The problem here is that even if a body parser should not parse (e.g. because the content type does not match), the parser still sets
req.body = {}
. This led another tool to think that parsing had already occurred, becausereq.body
was defined.I was wondering if it is possible to not modify the request at all if parsing should not be performed. That is the behavior I would expect.
You can see an example of this behavior in the raw parser here:
body-parser/lib/types/raw.js
Lines 62 to 78 in 090a92b
Thank you!
The text was updated successfully, but these errors were encountered: