Skip to content

Commit ef5f42f

Browse files
committed
test: fix http agent keep-alive server hint test case 4
Node's http.Server automatically sends Keep-Alive: timeout=65 on every keep-alive response unless keepAliveTimeout is set to 0. Case 4 assumed no hint would be sent with a plain createServer(), which was incorrect. Use { keepAliveTimeout: 0 } to suppress the automatic header and correctly test the no-hint code path. Refs: #66734 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
1 parent 5a3ecad commit ef5f42f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎test/parallel/test-http-agent-keep-alive-server-hint.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,16 @@ function getIdleSocket(agent) {
128128
}));
129129
}
130130

131-
// Case 4: No Keep-Alive header from server, no agent timeout.
131+
// Case 4: Server sends no Keep-Alive hint (keepAliveTimeout: 0 suppresses the
132+
// automatic header), no agent timeout.
132133
// Expected: socket.timeout === 0 (no timer set — existing behaviour unchanged).
133134
{
134-
const server = http.createServer(common.mustCall((req, res) => {
135-
res.end('ok');
136-
}));
135+
const server = http.createServer(
136+
{ keepAliveTimeout: 0 },
137+
common.mustCall((req, res) => {
138+
res.end('ok');
139+
})
140+
);
137141

138142
server.listen(0, common.mustCall(() => {
139143
const agent = new http.Agent({ keepAlive: true });

0 commit comments

Comments
 (0)