• 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 body =
9  '<html><head></head><body><h1>this is some data</h2></body></html>';
10
11const server = http2.createServer((req, res) => {
12  res.setHeader('foobar', 'baz');
13  res.setHeader('X-POWERED-BY', 'node-test');
14  res.setHeader('connection', 'connection-test');
15  res.end(body);
16});
17
18server.listen(0, common.mustCall(() => {
19  const client = http2.connect(`http://localhost:${server.address().port}`);
20  const headers = { ':path': '/' };
21  const req = client.request(headers);
22  req.setEncoding('utf8');
23  req.on('response', common.mustCall(function(headers) {
24    assert.strictEqual(headers.foobar, 'baz');
25    assert.strictEqual(headers['x-powered-by'], 'node-test');
26  }));
27
28  let data = '';
29  req.on('data', (d) => data += d);
30  req.on('end', () => {
31    assert.strictEqual(body, data);
32    server.close();
33    client.close();
34  });
35  req.end();
36}));
37
38const compatMsg = 'The provided connection header is not valid, ' +
39                  'the value will be dropped from the header and ' +
40                  'will never be in use.';
41
42common.expectWarning('UnsupportedWarning', compatMsg);
43
44server.on('error', common.mustNotCall());
45