• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6const assert = require('assert');
7const http2 = require('http2');
8const Countdown = require('../common/countdown');
9
10const server = http2.createServer();
11server.on('stream', common.mustCall((stream, headers) => {
12  const check = headers[':method'] === 'GET' ? true : false;
13  assert.strictEqual(stream.endAfterHeaders, check);
14  stream.on('data', common.mustNotCall());
15  stream.on('end', common.mustCall());
16  stream.respond();
17  stream.end('ok');
18}, 2));
19
20const countdown = new Countdown(2, () => server.close());
21
22server.listen(0, common.mustCall(() => {
23  {
24    const client = http2.connect(`http://localhost:${server.address().port}`);
25    const req = client.request();
26
27    req.resume();
28    req.on('response', common.mustCall(() => {
29      assert.strictEqual(req.endAfterHeaders, false);
30    }));
31    req.on('end', common.mustCall(() => {
32      client.close();
33      countdown.dec();
34    }));
35  }
36  {
37    const client = http2.connect(`http://localhost:${server.address().port}`);
38    const req = client.request({ ':method': 'POST' });
39
40    req.resume();
41    req.end();
42    req.on('response', common.mustCall(() => {
43      assert.strictEqual(req.endAfterHeaders, false);
44    }));
45    req.on('end', common.mustCall(() => {
46      client.close();
47      countdown.dec();
48    }));
49  }
50}));
51