summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-unknown-protocol.js
blob: 639bbe4f2d6ab4bcb7203d909ca6a8544d034b14 (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
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');

// This test verifies that when a server receives an unknownProtocol it will
// not leave the socket open if the client does not close it.

if (!common.hasCrypto)
  common.skip('missing crypto');

const h2 = require('http2');
const tls = require('tls');

const server = h2.createSecureServer({
  key: fixtures.readKey('rsa_private.pem'),
  cert: fixtures.readKey('rsa_cert.crt'),
  unknownProtocolTimeout: 500,
  allowHalfOpen: true
});

server.on('connection', (socket) => {
  socket.on('close', common.mustCall(() => {
    server.close();
  }));
});

server.listen(0, function() {
  tls.connect({
    port: server.address().port,
    rejectUnauthorized: false,
    ALPNProtocols: ['bogus']
  });
});