Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bubble up 'aborted' events from request

Right now those can either mean that the socket had a 'timeout', or 'close'
event before finishing the request. I'll propose a node patch that will allow
seperating the two issues in the future.
  • Loading branch information...
commit 4a752bb95270bb75bf98fe96ed6d6142ebd8aa2a 1 parent 0db3a1f
@felixge authored
Showing with 15 additions and 3 deletions.
  1. +3 −0  lib/incoming_form.js
  2. +12 −3 test/simple/test-incoming-form.js
View
3  lib/incoming_form.js
@@ -69,6 +69,9 @@ IncomingForm.prototype.parse = function(req, cb) {
.on('error', function(err) {
self._error(err);
})
+ .on('aborted', function() {
+ self.emit('aborted');
+ })
.on('data', function(buffer) {
self.write(buffer);
})
View
15 test/simple/test-incoming-form.js
@@ -60,7 +60,7 @@ test(function parse() {
assert.strictEqual(headers, REQ.headers);
});
- var events = ['error', 'data', 'end'];
+ var events = ['error', 'aborted', 'data', 'end'];
gently.expect(REQ, 'on', events.length, function(event, fn) {
assert.equal(event, events.shift());
emit[event] = fn;
@@ -139,6 +139,15 @@ test(function parse() {
emit.error(ERR);
})();
+ (function testEmitAborted() {
+ gently.expect(form, 'emit',function(event) {
+ assert.equal(event, 'aborted');
+ });
+
+ emit.aborted();
+ })();
+
+
(function testEmitData() {
var BUFFER = [1, 2, 3];
gently.expect(form, 'write', function(buffer) {
@@ -181,7 +190,7 @@ test(function parse() {
parseCalled = 0;
gently.expect(form, 'writeHeaders');
- gently.expect(REQ, 'on', 3, function() {
+ gently.expect(REQ, 'on', 4, function() {
return this;
});
@@ -210,7 +219,7 @@ test(function parse() {
}));
gently.expect(form, 'writeHeaders');
- gently.expect(REQ, 'on', 3, function() {
+ gently.expect(REQ, 'on', 4, function() {
return this;
});
Please sign in to comment.
Something went wrong with that request. Please try again.