mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
806 B
33 lines
806 B
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
var options = {
|
|
method: 'GET',
|
|
port: undefined,
|
|
host: '127.0.0.1',
|
|
path: '/',
|
|
timeout: 1
|
|
};
|
|
|
|
var server = http.createServer();
|
|
|
|
server.listen(0, options.host, function() {
|
|
options.port = this.address().port;
|
|
var req = http.request(options);
|
|
req.on('error', function() {
|
|
// this space is intentionally left blank
|
|
});
|
|
req.on('close', common.mustCall(() => server.close()));
|
|
|
|
var timeout_events = 0;
|
|
req.on('timeout', common.mustCall(() => timeout_events += 1));
|
|
setTimeout(function() {
|
|
req.destroy();
|
|
assert.strictEqual(timeout_events, 1);
|
|
}, common.platformTimeout(100));
|
|
setTimeout(function() {
|
|
req.end();
|
|
}, common.platformTimeout(10));
|
|
});
|
|
|