mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
bf37d4be69
This commit gives node.js the ability to also receive custom settings, in addition to sending, them which was implemented before. The custom settings received are limited to setting ids, that were specified before, when creating the session eithers through the server or the client. PR-URL: https://github.com/nodejs/node/pull/51323 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer({ maxSettings: 1 });
|
|
|
|
// TODO(@jasnell): There is still a session event
|
|
// emitted on the server side but it will be destroyed
|
|
// immediately after creation and there will be no
|
|
// stream created.
|
|
server.on('session', common.mustCall((session) => {
|
|
session.on('stream', common.mustNotCall());
|
|
session.on('remoteSettings', common.mustNotCall());
|
|
}, 2));
|
|
server.on('stream', common.mustNotCall());
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
// Specify two settings entries when a max of 1 is allowed.
|
|
// Connection should error immediately.
|
|
const client = http2.connect(
|
|
`http://localhost:${server.address().port}`, {
|
|
settings: {
|
|
// The actual settings values do not matter.
|
|
headerTableSize: 1000,
|
|
enablePush: false,
|
|
},
|
|
});
|
|
|
|
client.on('error', common.mustCall((err) => {
|
|
// The same but with custom settings
|
|
const client2 = http2.connect(
|
|
`http://localhost:${server.address().port}`, {
|
|
settings: {
|
|
// The actual settings values do not matter.
|
|
headerTableSize: 1000,
|
|
customSettings: {
|
|
0x14: 45
|
|
}
|
|
},
|
|
});
|
|
|
|
client2.on('error', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
}));
|
|
|
|
|
|
}));
|