From c9dbaeca21283e45c5717c1d2fa2d7fd190d94f5 Mon Sep 17 00:00:00 2001 From: Steve Krenek Date: Wed, 30 Apr 2014 14:15:55 -0500 Subject: [PATCH] Updating body-parser to 1.0.2 to fix FB 17150. --- lib/middleware.js | 15 ++------------- package.json | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/middleware.js b/lib/middleware.js index e626e3f..eba5e46 100755 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -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; @@ -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() { diff --git a/package.json b/package.json index c78b665..62e0d6d 100644 --- a/package.json +++ b/package.json @@ -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": {