mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
51e8f28dcc
Both http and https modules have server.timeout property in public API. This commit adds documentation section and test for server.timeout in http2 module, so it becomes consistent with http and https. Also improves description of callback argument in documentation for server.setTimeout(). PR-URL: https://github.com/nodejs/node/pull/31693 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
32 lines
899 B
JavaScript
Executable File
32 lines
899 B
JavaScript
Executable File
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const http2 = require('http2');
|
|
|
|
function testServerTimeout(setTimeoutFn) {
|
|
const server = http2.createServer();
|
|
setTimeoutFn(server);
|
|
|
|
const onServerTimeout = common.mustCall((session) => {
|
|
session.close();
|
|
});
|
|
|
|
server.on('stream', common.mustNotCall());
|
|
server.once('timeout', onServerTimeout);
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const url = `http://localhost:${server.address().port}`;
|
|
const client = http2.connect(url);
|
|
client.on('close', common.mustCall(() => {
|
|
const client2 = http2.connect(url);
|
|
client2.on('close', common.mustCall(() => server.close()));
|
|
}));
|
|
}));
|
|
}
|
|
|
|
const timeout = common.platformTimeout(50);
|
|
testServerTimeout((server) => server.setTimeout(timeout));
|
|
testServerTimeout((server) => server.timeout = timeout);
|