Skip to content

Commit

Permalink
In addition to 'aborted' emit 'close' from incoming requests
Browse files Browse the repository at this point in the history
Closes nodejsGH-160.
  • Loading branch information
felixge authored and ry committed Feb 24, 2011
1 parent 5287703 commit f423ec9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/http.js
Expand Up @@ -952,6 +952,7 @@ function connectionListener(socket) {
while (incoming.length) {
var req = incoming.shift();
req.emit('aborted');
req.emit('close');
}
// abort socket._httpMessage ?
}
Expand Down
34 changes: 34 additions & 0 deletions test/simple/test-http-response-close.js
@@ -0,0 +1,34 @@
var common = require('../common');
var assert = require('assert');
var http = require('http');

var gotEnd = false;

var server = http.createServer(function(req, res) {
res.writeHead(200);
res.write('a');

req.on('close', function() {
console.error("aborted");
gotEnd = true;
});
});
server.listen(common.PORT);

server.addListener('listening', function() {
console.error("make req");
http.get({
port: common.PORT
}, function(res) {
console.error("got res");
res.on('data', function(data) {
console.error("destroy res");
res.destroy();
server.close();
});
});
});

process.on('exit', function() {
assert.ok(gotEnd);
});

0 comments on commit f423ec9

Please sign in to comment.