Permalink
Browse files

flag error since formidable still emits "end"

  • Loading branch information...
1 parent 78773bf commit e1de4f898883fdb77b9a42478cd7e124cdee8e62 @tj tj committed Nov 17, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/middleware/bodyParser.js
View
9 lib/middleware/bodyParser.js
@@ -131,7 +131,8 @@ exports.parse['application/json'] = function(req, options, fn){
exports.parse['multipart/form-data'] = function(req, options, fn){
var form = new formidable.IncomingForm
, query = []
- , files = {};
+ , files = {}
+ , done;
Object.keys(options).forEach(function(key){
form[key] = options[key];
@@ -151,9 +152,13 @@ exports.parse['multipart/form-data'] = function(req, options, fn){
}
});
- form.on('error', fn);
+ form.on('error', function(err){
+ fn(err);
+ done = true;
+ });
form.on('end', function(){
+ if (done) return;
try {
query = query.join('&');
query = qs.parse(query);

0 comments on commit e1de4f8

Please sign in to comment.