blob: 79aa6ba46b6579abe89d90c93d9855f32310797c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
'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));
});
|