mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Single-use requests otherwise wait for the keep-alive timeout. Use nonpersistent agents where agent selection is unrelated to coverage. For default-agent tests, close the server after consuming the response. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/65980 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
26 lines
522 B
JavaScript
26 lines
522 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
res.write('okay', common.mustCall(() => {
|
|
delete res.socket.parser;
|
|
}));
|
|
res.end();
|
|
}));
|
|
|
|
server.listen(0, '127.0.0.1', common.mustCall(() => {
|
|
const req = http.request({
|
|
agent: false,
|
|
port: server.address().port,
|
|
host: '127.0.0.1',
|
|
method: 'GET',
|
|
});
|
|
req.end();
|
|
}));
|
|
|
|
server.unref();
|