Added `defer` property to multipart() middleware #664

Merged
merged 3 commits into from Oct 2, 2012

2 participants

@bminer

The newly added defer property allows one to defer mulitpart parsing and immediately execute the next middleware. In this case, Formidable's form object is exposed via req.form, allowing middleware to bind to "progress", "error", and/or "end" events.

Fixes issue #638

bminer added some commits Oct 2, 2012
@bminer bminer Added `defer` property to multipart() middleware
The newly added `defer` property allows one to defer mulitpart parsing and
immediately execute the next middleware. In this case, Formidable's form
object is exposed via `req.form`, allowing middleware to bind to "progress",
"error", and/or "end" events.
7626549
@bminer bminer Fixed a bug introduced when adding `defer` option to multipart() midd…
…leware
9f7427a
@tj tj and 1 other commented on an outdated diff Oct 2, 2012
lib/middleware/multipart.js
@@ -99,8 +102,10 @@ exports = module.exports = function(options){
});
form.on('error', function(err){
- err.status = 400;
- next(err);
+ if(!options.defer) {
@tj
Sencha Labs member
tj added a note Oct 2, 2012

if ( for these, and we need a test or two, rest looks good thanks!

@bminer
bminer added a note Oct 2, 2012

Should be if(!options.defer)... if we don't defer, then it's safe to call next() here. If we do defer, we shouldn't call next() again, right? I've always wondered... what happens if you res.send(...) and then call next(err)???

@tj
Sencha Labs member
tj added a note Oct 2, 2012

no i just mean if ( add a space :D haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bminer bminer Minor style changes
Added tests for `defer` option in multipart() middleware
ff36e83
@bminer

@visionmedia - Made a few of your suggested changes. Please let me know if you need anything else. :)

@tj tj merged commit cb80fcd into senchalabs:master Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment