summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-http1-client.js
blob: 394993d4d72088cb37e089f143a5b1bc1feb0747 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
// Flags: --expose-internals

const common = require('../common');

if (!common.hasCrypto)
  common.skip('missing crypto');

const http = require('http');
const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');

const server = http2.createServer();
server.on('stream', common.mustNotCall());
server.on('session', common.mustCall((session) => {
  session.on('close', common.mustCall());
  session.on('error', common.expectsError({
    code: 'ERR_HTTP2_ERROR',
    type: NghttpError,
    message: 'Received bad client magic byte string'
  }));
}));

server.listen(0, common.mustCall(() => {
  const req = http.get(`http://localhost:${server.address().port}`);
  req.on('error', (error) => server.close());
}));