Skip to content

Commit

Permalink
Merge pull request #283 from skrenek/master
Browse files Browse the repository at this point in the history
Updating body-parser to 1.0.2 to fix FB 17150.
  • Loading branch information
skrenek committed Apr 30, 2014
2 parents 94fdfeb + c9dbaec commit 08ce293
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
15 changes: 2 additions & 13 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ exports.getMiddleware = function(options, cb) {

// If ignorePaths contains this request's path and the HTTP method matches, skip the connect bodyParser.
var pathname = nodeUrl.parse(req.url).pathname,
currReqMethod = req.method.toLowerCase(),
bodyParserInUse = bodyParserMiddleware;
currReqMethod = req.method.toLowerCase();

var ignorePath = _.find(bodyParserIgnorePaths, function(ignorePathObj) {
return ignorePathObj.regex.test(pathname) && ignorePathObj.method === currReqMethod;
Expand All @@ -156,17 +155,7 @@ exports.getMiddleware = function(options, cb) {
next();
} else {

// This works around an oversight in the connect body parser middleware. DELETE
// requests are not required to have a body, but the body parser middleware throws a 400 for them if they do not.
// See https://github.com/expressjs/body-parser/issues/12
if (currReqMethod === 'delete' && ! req.headers['content-length']) {
bodyParserInUse = function(req, res, next) {
req._body = true;
req.body = {};
next();
};
}
bodyParserInUse(req, res, function(err) {
bodyParserMiddleware(req, res, function(err) {
if (err) return next(err);
if (! req._body) {
multerMiddleware(req, res, function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"cookie": "~0.1.0",
"file": "~0.2.1",
"multer": "0.0.5",
"body-parser": "~1.0.1",
"body-parser": "~1.0.2",
"heapdump": "~0.2.7"
},
"devDependencies": {
Expand Down

0 comments on commit 08ce293

Please sign in to comment.