mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
http: add Agent.agentKeepAliveTimeoutBuffer option
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m45s
Coverage Linux / coverage-linux (push) Failing after 1m1s
Test and upload documentation to artifacts / build-docs (push) Failing after 6m37s
Linters / lint-addon-docs (push) Successful in 2m28s
Linters / lint-cpp (push) Successful in 4m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-py (push) Successful in 2m39s
Linters / lint-yaml (push) Successful in 2m32s
Linters / lint-sh (push) Failing after 1m41s
Linters / lint-codeowners (push) Failing after 56s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m24s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Linters / lint-js-and-md (push) Successful in 14m58s
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 52s
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m45s
Coverage Linux / coverage-linux (push) Failing after 1m1s
Test and upload documentation to artifacts / build-docs (push) Failing after 6m37s
Linters / lint-addon-docs (push) Successful in 2m28s
Linters / lint-cpp (push) Successful in 4m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-py (push) Successful in 2m39s
Linters / lint-yaml (push) Successful in 2m32s
Linters / lint-sh (push) Failing after 1m41s
Linters / lint-codeowners (push) Failing after 56s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m24s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Linters / lint-js-and-md (push) Successful in 14m58s
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 52s
PR-URL: https://github.com/nodejs/node/pull/59315 Reviewed-By: Jason Zhang <xzha4350@gmail.com>
This commit is contained in:
parent
bb6e8351c7
commit
a4b4eca94c
3 changed files with 64 additions and 3 deletions
44
test/parallel/test-http-agent-keep-alive-timeout-buffer.js
Normal file
44
test/parallel/test-http-agent-keep-alive-timeout-buffer.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
|
||||
// Ensure agentKeepAliveTimeoutBuffer option sets the correct value or falls back to default.
|
||||
{
|
||||
const agent1 = new http.Agent({ agentKeepAliveTimeoutBuffer: 1500, keepAlive: true });
|
||||
assert.strictEqual(agent1.agentKeepAliveTimeoutBuffer, 1500);
|
||||
|
||||
const agent2 = new http.Agent({ agentKeepAliveTimeoutBuffer: -100, keepAlive: true });
|
||||
assert.strictEqual(agent2.agentKeepAliveTimeoutBuffer, 1000);
|
||||
|
||||
const agent3 = new http.Agent({ agentKeepAliveTimeoutBuffer: Infinity, keepAlive: true });
|
||||
assert.strictEqual(agent3.agentKeepAliveTimeoutBuffer, 1000);
|
||||
|
||||
const agent4 = new http.Agent({ keepAlive: true });
|
||||
assert.strictEqual(agent4.agentKeepAliveTimeoutBuffer, 1000);
|
||||
}
|
||||
|
||||
// Integration test with server sending Keep-Alive timeout header.
|
||||
{
|
||||
const SERVER_TIMEOUT = 3;
|
||||
const BUFFER = 1500;
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
res.setHeader('Keep-Alive', `timeout=${SERVER_TIMEOUT}`);
|
||||
res.end('ok');
|
||||
});
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const agent = new http.Agent({ agentKeepAliveTimeoutBuffer: BUFFER, keepAlive: true });
|
||||
assert.strictEqual(agent.agentKeepAliveTimeoutBuffer, BUFFER);
|
||||
|
||||
http.get({ port: server.address().port, agent }, (res) => {
|
||||
res.resume();
|
||||
res.on('end', () => {
|
||||
agent.destroy();
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue