summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-max-settings.js
blob: 0ae792855ae3d566503ba40f9fafd6b3f5a117dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'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());
}));
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(() => {
    server.close();
  }));
}));