• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5if (!common.hasCrypto)
6  common.skip('missing crypto');
7
8const http2 = require('http2');
9const net = require('net');
10const h2test = require('../common/http2');
11
12const server = http2.createServer();
13server.on('stream', common.mustNotCall());
14
15const settings = new h2test.SettingsFrame();
16const settingsAck = new h2test.SettingsFrame(true);
17const altsvc = new h2test.AltSvcFrame((1 << 14) + 1);
18
19server.listen(0, () => {
20  const client = net.connect(server.address().port, () => {
21    client.write(h2test.kClientMagic, () => {
22      client.write(settings.data, () => {
23        client.write(settingsAck.data);
24        // Prior to nghttp2 1.31.1, sending this malformed altsvc frame
25        // would cause a segfault. This test is successful if a segfault
26        // does not occur.
27        client.write(altsvc.data, common.mustCall(() => {
28          client.destroy();
29        }));
30      });
31    });
32  });
33
34  // An error may or may not be emitted on the client side, we don't care
35  // either way if it is, but we don't want to die if it is.
36  client.on('error', () => {});
37  client.on('close', common.mustCall(() => server.close()));
38  client.resume();
39});
40