multiparty
Advanced tools
Comparing version 3.2.6 to 3.2.7
@@ -0,1 +1,5 @@ | ||
### 3.2.7 | ||
* Fix errors hanging responses in callback-style | ||
### 3.2.6 | ||
@@ -2,0 +6,0 @@ |
35
index.js
@@ -83,3 +83,5 @@ exports.Form = Form; | ||
Form.prototype.parse = function(req, cb) { | ||
var called = false; | ||
var self = this; | ||
var waitend = true; | ||
@@ -95,3 +97,7 @@ // if the user supplies a callback, this implies autoFields and autoFiles | ||
req.on('error', handleError); | ||
req.on('end', onReqEnd); | ||
req.on('error', function(err) { | ||
waitend = false; | ||
handleError(err); | ||
}); | ||
req.on('aborted', onReqAborted); | ||
@@ -131,2 +137,15 @@ | ||
self.on('error', function(err) { | ||
if (called) return; | ||
called = true; | ||
if (waitend && req.readable) { | ||
// dump rest of request | ||
req.resume(); | ||
req.once('end', function() { | ||
cb(err); | ||
}); | ||
return; | ||
} | ||
cb(err); | ||
@@ -148,2 +167,3 @@ }); | ||
function onReqAborted() { | ||
waitend = false; | ||
self.emit('aborted'); | ||
@@ -153,2 +173,6 @@ handleError(new Error("Request aborted")); | ||
function onReqEnd() { | ||
waitend = false; | ||
} | ||
function handleError(err) { | ||
@@ -159,8 +183,3 @@ var first = !self.error; | ||
req.removeListener('aborted', onReqAborted); | ||
// welp. 0.8 doesn't support unpipe, too bad so sad. | ||
// let's drop support for 0.8 soon. | ||
if (req.unpipe) { | ||
req.unpipe(self); | ||
} | ||
req.removeListener('end', onReqEnd); | ||
} | ||
@@ -181,2 +200,4 @@ | ||
Form.prototype._write = function(buffer, encoding, cb) { | ||
if (this.error) return; | ||
var self = this | ||
@@ -183,0 +204,0 @@ , i = 0 |
{ | ||
"name": "multiparty", | ||
"version": "3.2.6", | ||
"version": "3.2.7", | ||
"description": "multipart/form-data parser which supports streaming", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38139
608