-
-
Notifications
You must be signed in to change notification settings - Fork 747
Closed
Description
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:
Lines 62 to 78 in 090a92b
req.body = req.body || {} | |
// skip requests without bodies | |
if (!typeis.hasBody(req)) { | |
debug('skip empty body') | |
next() | |
return | |
} | |
debug('content-type %j', req.headers['content-type']) | |
// determine if request should be parsed | |
if (!shouldParse(req)) { | |
debug('skip parsing') | |
next() | |
return | |
} |
Thank you!
Metadata
Metadata
Assignees
Labels
No labels