• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests that attempting to send too many non-acknowledged
4// settings frames will result in an error
5
6const common = require('../common');
7if (!common.hasCrypto)
8  common.skip('missing crypto');
9const assert = require('assert');
10const h2 = require('http2');
11
12const maxOutstandingSettings = 2;
13
14function doTest(session) {
15  session.on('error', common.expectsError({
16    code: 'ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
17    name: 'Error'
18  }));
19  for (let n = 0; n < maxOutstandingSettings; n++) {
20    session.settings({ enablePush: false });
21    assert.strictEqual(session.pendingSettingsAck, true);
22  }
23}
24
25{
26  const server = h2.createServer({ maxOutstandingSettings });
27  server.on('stream', common.mustNotCall());
28  server.once('session', common.mustCall((session) => doTest(session)));
29
30  server.listen(0, common.mustCall(() => {
31    const client = h2.connect(`http://localhost:${server.address().port}`);
32    client.on('error', common.expectsError({
33      code: 'ERR_HTTP2_SESSION_ERROR',
34      message: 'Session closed with error code 2',
35    }));
36    client.on('close', common.mustCall(() => server.close()));
37  }));
38}
39
40{
41  const server = h2.createServer();
42  server.on('stream', common.mustNotCall());
43
44  server.listen(0, common.mustCall(() => {
45    const client = h2.connect(`http://localhost:${server.address().port}`,
46                              { maxOutstandingSettings });
47    client.on('connect', () => doTest(client));
48    client.on('close', () => server.close());
49  }));
50}
51