• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6const http2 = require('http2');
7const Countdown = require('../common/countdown');
8
9const server = http2.createServer();
10
11server.on('stream', common.mustNotCall());
12
13const count = 32;
14
15server.listen(0, common.mustCall(() => {
16  const client = http2.connect(`http://localhost:${server.address().port}`);
17  client.setMaxListeners(33);
18
19  const countdown = new Countdown(count + 1, () => {
20    server.close();
21    client.close();
22  });
23
24  // nghttp2 will catch the bad header value for us.
25  function doTest(i) {
26    const req = client.request({ ':path': `bad${String.fromCharCode(i)}path` });
27    req.on('error', common.expectsError({
28      code: 'ERR_HTTP2_STREAM_ERROR',
29      name: 'Error',
30      message: 'Stream closed with error code NGHTTP2_PROTOCOL_ERROR'
31    }));
32    req.on('close', common.mustCall(() => countdown.dec()));
33  }
34
35  for (let i = 0; i <= count; i += 1)
36    doTest(i);
37}));
38