Allows upstream middleware to consume and manipulate message body and still use bodyParser. #356

wants to merge 1 commit into

2 participants


Currently, if an upstream middleware consumes http(s).ServerRequest's message body events and valid json/form header are set then bodyParser will never complete it's attempt at getting the message body. This update allows earlier middleware to set req.rawBody, which will be used instead, avoiding the hang and allowing consumption and manipulation of the message body prior to parsing by bodyParser.

I noticed that as of the 10th, rawBody was removed. If desired, rawBody could be unset by bodyParser after parsing.

Sencha Labs member
tj commented Aug 28, 2011

I dont think we really need to complicate it, it's easy enough to just use JSON.parse etc directly (though if you wanted to you could still use connect.bodyParser.parse[mime]


The idea is to consolidate concerns. Yes, one could call the needed parsers directly, but either you end up doing ALL the parsing in the new middleware or you end up with parsing happening in multiple locations. Why write/maintain your own parsing middleware when connect provides a great one already?

@ryanrolds ryanrolds closed this Sep 4, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment