mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
http: add server.keepAliveTimeoutBuffer option
PR-URL: https://github.com/nodejs/node/pull/59243 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
This commit is contained in:
parent
5bea645e4b
commit
f7c2a7ed4a
3 changed files with 83 additions and 8 deletions
39
test/parallel/test-http-keep-alive-timeout-buffer.js
Normal file
39
test/parallel/test-http-keep-alive-timeout-buffer.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const http = require('http');
|
||||
const assert = require('assert');
|
||||
|
||||
const server = http.createServer(common.mustCall((req, res) => {
|
||||
const body = 'buffer test\n';
|
||||
|
||||
res.writeHead(200, { 'Content-Length': body.length });
|
||||
res.write(body);
|
||||
res.end();
|
||||
}));
|
||||
|
||||
server.keepAliveTimeout = 100;
|
||||
|
||||
if (server.keepAliveTimeoutBuffer === undefined) {
|
||||
server.keepAliveTimeoutBuffer = 1000;
|
||||
}
|
||||
assert.strictEqual(server.keepAliveTimeoutBuffer, 1000);
|
||||
|
||||
server.listen(0, () => {
|
||||
http.get({
|
||||
port: server.address().port,
|
||||
path: '/',
|
||||
}, (res) => {
|
||||
res.resume();
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
|
||||
{
|
||||
const customBuffer = 3000;
|
||||
const server = http.createServer(() => {});
|
||||
server.keepAliveTimeout = 200;
|
||||
server.keepAliveTimeoutBuffer = customBuffer;
|
||||
assert.strictEqual(server.keepAliveTimeoutBuffer, customBuffer);
|
||||
server.close();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue