2011-02-20 13:31:37 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var http = require('http');
|
|
|
|
|
2012-01-05 12:50:03 +01:00
|
|
|
var requestGotEnd = false;
|
|
|
|
var responseGotEnd = false;
|
2011-02-20 13:31:37 +01:00
|
|
|
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
res.writeHead(200);
|
|
|
|
res.write('a');
|
|
|
|
|
|
|
|
req.on('close', function() {
|
2012-01-05 12:50:03 +01:00
|
|
|
console.error('request aborted');
|
|
|
|
requestGotEnd = true;
|
|
|
|
});
|
|
|
|
res.on('close', function() {
|
|
|
|
console.error('response aborted');
|
|
|
|
responseGotEnd = true;
|
2011-02-20 13:31:37 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
server.listen(common.PORT);
|
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
server.on('listening', function() {
|
2011-10-05 00:08:18 +02:00
|
|
|
console.error('make req');
|
2011-02-20 13:31:37 +01:00
|
|
|
http.get({
|
|
|
|
port: common.PORT
|
|
|
|
}, function(res) {
|
2011-10-05 00:08:18 +02:00
|
|
|
console.error('got res');
|
2011-02-20 13:31:37 +01:00
|
|
|
res.on('data', function(data) {
|
2011-10-05 00:08:18 +02:00
|
|
|
console.error('destroy res');
|
2011-02-20 13:31:37 +01:00
|
|
|
res.destroy();
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
2012-01-05 12:50:03 +01:00
|
|
|
assert.ok(requestGotEnd);
|
|
|
|
assert.ok(responseGotEnd);
|
2011-02-20 13:31:37 +01:00
|
|
|
});
|