1'use strict'; 2// Flags: --expose-internals 3 4const common = require('../common'); 5 6if (!common.hasCrypto) 7 common.skip('missing crypto'); 8 9const http = require('http'); 10const http2 = require('http2'); 11const { NghttpError } = require('internal/http2/util'); 12 13const server = http2.createServer(); 14server.on('stream', common.mustNotCall()); 15server.on('session', common.mustCall((session) => { 16 session.on('close', common.mustCall()); 17 session.on('error', common.expectsError({ 18 code: 'ERR_HTTP2_ERROR', 19 constructor: NghttpError, 20 message: 'Received bad client magic byte string' 21 })); 22})); 23 24server.listen(0, common.mustCall(() => { 25 const req = http.get(`http://localhost:${server.address().port}`); 26 req.on('error', (error) => server.close()); 27})); 28