summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-session-destroy.js
blob: 9b7f126510757c07ae1132e6d9a336103e9dc757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');
const h2 = require('http2');

const server = h2.createServer();
server.listen(0, common.localhostIPv4, common.mustCall(() => {
  const afterConnect = common.mustCall((session) => {
    session.request({ ':method': 'POST' }).end(common.mustCall(() => {
      session.destroy();
      server.close();
    }));
  });

  const port = server.address().port;
  const host = common.localhostIPv4;
  h2.connect('http://' + host + ':' + port, afterConnect);
}));