• 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 assert = require('assert');
8
9const server = http2.createServer();
10
11// Check that stream ends immediately after respond on :status 204, 205 & 304
12
13const status = [204, 205, 304];
14
15server.on('stream', common.mustCall((stream) => {
16  stream.on('close', common.mustCall(() => {
17    assert.strictEqual(stream.destroyed, true);
18  }));
19  stream.respond({ ':status': status.shift() });
20}, 3));
21
22server.listen(0, common.mustCall(makeRequest));
23
24function makeRequest() {
25  const client = http2.connect(`http://localhost:${server.address().port}`);
26  const req = client.request();
27  req.resume();
28
29  req.on('end', common.mustCall(() => {
30    client.close();
31
32    if (!status.length) {
33      server.close();
34    } else {
35      makeRequest();
36    }
37  }));
38  req.end();
39}
40