summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-http1-client.js
blob: 40e97f04a4e8882dca14bcead9123531e016460f (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',
    constructor: 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());
}));