mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
f63e8b7fa7
PR-URL: https://github.com/nodejs/node/pull/51900 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
56 lines
969 B
JavaScript
56 lines
969 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
tmpdir.refresh();
|
|
|
|
let count = 0;
|
|
let server1;
|
|
let server2;
|
|
|
|
function request(options) {
|
|
count++;
|
|
http.get({
|
|
...options,
|
|
createConnection: (...args) => {
|
|
return net.connect(...args);
|
|
}
|
|
}, (res) => {
|
|
res.resume();
|
|
res.on('end', () => {
|
|
if (--count === 0) {
|
|
server1.close();
|
|
server2.close();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
server1 = http.createServer((req, res) => {
|
|
res.end('ok');
|
|
}).listen(common.PIPE, () => {
|
|
server2 = http.createServer((req, res) => {
|
|
res.end('ok');
|
|
}).listen(() => {
|
|
request({
|
|
path: '/',
|
|
socketPath: common.PIPE,
|
|
});
|
|
|
|
request({
|
|
socketPath: common.PIPE,
|
|
});
|
|
|
|
request({
|
|
path: '/',
|
|
port: server2.address().port,
|
|
});
|
|
|
|
request({
|
|
port: server2.address().port,
|
|
});
|
|
});
|
|
});
|