• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6const h2 = require('http2');
7
8const server = h2.createServer();
9
10// We use the lower-level API here
11server.on('stream', common.mustCall(onStream));
12
13function onStream(stream, headers, flags) {
14  stream.respond(undefined, { waitForTrailers: true });
15  // There is no wantTrailers handler so this should close naturally
16  // without hanging. If the test completes without timing out, then
17  // it passes.
18  stream.end('ok');
19}
20
21server.listen(0);
22
23server.on('listening', common.mustCall(function() {
24  const client = h2.connect(`http://localhost:${this.address().port}`);
25  const req = client.request();
26  req.resume();
27  req.on('trailers', common.mustNotCall());
28  req.on('close', common.mustCall(() => {
29    server.close();
30    client.close();
31  }));
32}));
33