mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
af15b755c0
Reasons: - `test-async-wrap-getasyncid` binds a handle, so move to sequential because port cannot be already in use. - `test-dgram-implicit-bind-failure` requires a hardcoded port number to properly send socket packet. - `test-http-agent-uninitialized-with-handle` requires a hardcoded port number to properly send http request. - `test-http-agent-uninitialized` requires a hardcoded port number to properly send http request. - `test-net-localport` requires a hardcoded port number for assertions. In addition this replaces two common.PORTs with a dynamic port. PR-URL: https://github.com/nodejs/node/pull/15151 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
27 lines
726 B
JavaScript
27 lines
726 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
|
|
const agent = new http.Agent({
|
|
keepAlive: true,
|
|
});
|
|
const socket = new net.Socket();
|
|
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
res.end();
|
|
})).listen(0, common.mustCall(() => {
|
|
const req = new http.ClientRequest(`http://localhost:${server.address().port}/`);
|
|
|
|
// Manually add the socket without a _handle.
|
|
agent.freeSockets[agent.getName(req)] = [socket];
|
|
// Now force the agent to use the socket and check that _handle exists before
|
|
// calling asyncReset().
|
|
agent.addRequest(req, {});
|
|
req.on('response', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
req.end();
|
|
}));
|