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>
29 lines
696 B
JavaScript
29 lines
696 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
// Test providing both a url and options, with the options partially
|
|
// replacing address and port portions of the URL provided.
|
|
{
|
|
const server = http.createServer(
|
|
common.mustCall((req, res) => {
|
|
assert.strictEqual(req.url, '/testpath');
|
|
res.end();
|
|
server.close();
|
|
})
|
|
);
|
|
server.listen(
|
|
0,
|
|
common.mustCall(() => {
|
|
http.get(
|
|
'http://example.com/testpath',
|
|
{ hostname: 'localhost', port: server.address().port, agent: false },
|
|
common.mustCall((res) => {
|
|
res.resume();
|
|
})
|
|
);
|
|
})
|
|
);
|
|
}
|