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 server = http2.createServer();
10
11const src = Object.create(null);
12src['www-authenticate'] = 'foo';
13src['WWW-Authenticate'] = 'bar';
14src['WWW-AUTHENTICATE'] = 'baz';
15src.test = 'foo, bar, baz';
16
17server.on('stream', common.mustCall((stream, headers, flags, rawHeaders) => {
18  const expected = [
19    ':method',
20    'GET',
21    ':authority',
22    `localhost:${server.address().port}`,
23    ':scheme',
24    'http',
25    ':path',
26    '/',
27    'www-authenticate',
28    'foo',
29    'www-authenticate',
30    'bar',
31    'www-authenticate',
32    'baz',
33    'test',
34    'foo, bar, baz',
35  ];
36
37  assert.deepStrictEqual(rawHeaders, expected);
38  stream.respond(src);
39  stream.end();
40}));
41
42server.listen(0, common.mustCall(() => {
43  const client = http2.connect(`http://localhost:${server.address().port}`);
44  const req = client.request(src);
45  req.on('close', common.mustCall(() => {
46    server.close();
47    client.close();
48  }));
49}));
50