2013-03-04 21:44:56 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var http = require('http');
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
method: 'GET',
|
|
|
|
port: common.PORT,
|
|
|
|
host: '127.0.0.1',
|
|
|
|
path: '/'
|
|
|
|
};
|
|
|
|
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
// this space intentionally left blank
|
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(options.port, options.host, function() {
|
|
|
|
var req = http.request(options, function(res) {
|
|
|
|
// this space intentionally left blank
|
|
|
|
});
|
|
|
|
req.on('error', function() {
|
2013-08-13 00:01:05 +02:00
|
|
|
// this space is intentionally left blank
|
2013-03-04 21:44:56 +01:00
|
|
|
});
|
|
|
|
req.on('close', function() {
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
var timeout_events = 0;
|
|
|
|
req.setTimeout(1);
|
|
|
|
req.on('timeout', function () {
|
|
|
|
timeout_events += 1;
|
|
|
|
});
|
|
|
|
setTimeout(function () {
|
|
|
|
req.destroy();
|
|
|
|
assert.equal(timeout_events, 1);
|
2013-05-25 02:16:08 +02:00
|
|
|
}, 100);
|
2013-04-08 14:40:31 +02:00
|
|
|
setTimeout(function () {
|
|
|
|
req.end();
|
2013-05-25 02:16:08 +02:00
|
|
|
}, 50);
|
2013-03-04 21:44:56 +01:00
|
|
|
});
|