mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
34 lines
812 B
JavaScript
34 lines
812 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const options = {
|
|
method: 'GET',
|
|
port: undefined,
|
|
host: '127.0.0.1',
|
|
path: '/',
|
|
timeout: 1
|
|
};
|
|
|
|
const server = http.createServer();
|
|
|
|
server.listen(0, options.host, function() {
|
|
options.port = this.address().port;
|
|
const req = http.request(options);
|
|
req.on('error', function() {
|
|
// this space is intentionally left blank
|
|
});
|
|
req.on('close', common.mustCall(() => server.close()));
|
|
|
|
let 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));
|
|
});
|