• 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');
8
9const options = {};
10
11const server = http2.createServer(options);
12
13// Options are defaulted but the options are not modified
14assert.deepStrictEqual(Object.keys(options), []);
15
16server.on('stream', common.mustCall((stream) => {
17  const headers = {};
18  const options = {};
19  stream.respond(headers, options);
20
21  // The headers are defaulted but the original object is not modified
22  assert.deepStrictEqual(Object.keys(headers), []);
23
24  // Options are defaulted but the original object is not modified
25  assert.deepStrictEqual(Object.keys(options), []);
26
27  stream.end();
28}));
29
30server.listen(0, common.mustCall(() => {
31  const client = http2.connect(`http://localhost:${server.address().port}`);
32
33  const headers = {};
34  const options = {};
35
36  const req = client.request(headers, options);
37
38  // The headers are defaulted but the original object is not modified
39  assert.deepStrictEqual(Object.keys(headers), []);
40
41  // Options are defaulted but the original object is not modified
42  assert.deepStrictEqual(Object.keys(options), []);
43
44  req.resume();
45  req.on('end', common.mustCall(() => {
46    server.close();
47    client.close();
48  }));
49}));
50