2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-08-31 01:00:41 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
2013-03-04 22:44:56 +02:00
|
|
|
|
|
|
|
var options = {
|
|
|
|
method: 'GET',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: undefined,
|
2013-03-04 22:44:56 +02:00
|
|
|
host: '127.0.0.1',
|
|
|
|
path: '/'
|
|
|
|
};
|
|
|
|
|
2016-08-31 01:00:41 +01:00
|
|
|
var server = http.createServer();
|
2013-03-04 22:44:56 +02:00
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, options.host, function() {
|
|
|
|
options.port = this.address().port;
|
2016-08-31 01:00:41 +01:00
|
|
|
var req = http.request(options);
|
2013-03-04 22:44:56 +02:00
|
|
|
req.on('error', function() {
|
2013-08-12 15:01:05 -07:00
|
|
|
// this space is intentionally left blank
|
2013-03-04 22:44:56 +02:00
|
|
|
});
|
2016-08-31 01:00:41 +01:00
|
|
|
req.on('close', common.mustCall(() => server.close()));
|
2013-03-04 22:44:56 +02:00
|
|
|
|
|
|
|
var timeout_events = 0;
|
|
|
|
req.setTimeout(1);
|
2016-08-31 01:00:41 +01:00
|
|
|
req.on('timeout', common.mustCall(() => timeout_events += 1));
|
2015-05-19 13:00:06 +02:00
|
|
|
setTimeout(function() {
|
2013-03-04 22:44:56 +02:00
|
|
|
req.destroy();
|
2016-08-31 01:00:41 +01:00
|
|
|
assert.strictEqual(timeout_events, 1);
|
2015-11-21 20:10:52 -08:00
|
|
|
}, common.platformTimeout(100));
|
2015-05-19 13:00:06 +02:00
|
|
|
setTimeout(function() {
|
2013-04-08 16:40:31 +04:00
|
|
|
req.end();
|
2015-11-21 20:10:52 -08:00
|
|
|
}, common.platformTimeout(50));
|
2013-03-04 22:44:56 +02:00
|
|
|
});
|