1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const h2 = require('http2'); 7 8const server = h2.createServer(); 9 10// We use the lower-level API here 11server.on('stream', common.mustCall(onStream)); 12 13function onStream(stream, headers, flags) { 14 stream.session.goaway(1); 15 stream.respond(); 16 stream.end('data'); 17} 18 19server.listen(0); 20 21server.on('listening', common.mustCall(() => { 22 const client = h2.connect(`http://localhost:${server.address().port}`); 23 24 client.on('goaway', common.mustCall()); 25 client.on('error', common.expectsError({ 26 code: 'ERR_HTTP2_SESSION_ERROR' 27 })); 28 29 const req = client.request(); 30 req.on('error', common.expectsError({ 31 code: 'ERR_HTTP2_SESSION_ERROR' 32 })); 33 req.resume(); 34 req.on('data', common.mustNotCall()); 35 req.on('end', common.mustCall(() => server.close())); 36})); 37