2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-08-31 01:00:41 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const http = require('http');
|
2013-03-04 22:44:56 +02:00
|
|
|
|
2016-12-15 13:31:36 -08:00
|
|
|
const options = {
|
2013-03-04 22:44:56 +02:00
|
|
|
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-12-15 13:31:36 -08:00
|
|
|
const 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-12-15 13:31:36 -08:00
|
|
|
const 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
|
|
|
|
|
|
|
req.setTimeout(1);
|
2016-12-15 13:31:36 -08:00
|
|
|
req.on('timeout', common.mustCall(() => {
|
|
|
|
req.end(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
req.destroy();
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
}));
|
2013-03-04 22:44:56 +02:00
|
|
|
});
|