1'use strict'; 2const common = require('../common'); 3const fixtures = require('../common/fixtures'); 4if (!common.hasCrypto) { 5 common.skip('missing crypto'); 6} 7 8const http2 = require('http2'); 9const key = fixtures.readKey('agent1-key.pem', 'binary'); 10const cert = fixtures.readKey('agent1-cert.pem', 'binary'); 11 12const server = http2.createSecureServer({ key, cert }); 13 14let client_stream; 15 16server.on('stream', common.mustCall(function(stream) { 17 stream.resume(); 18 stream.on('data', function(chunk) { 19 stream.write(chunk); 20 client_stream.pause(); 21 client_stream.close(http2.constants.NGHTTP2_CANCEL); 22 }); 23})); 24 25server.listen(0, function() { 26 const client = http2.connect(`https://localhost:${server.address().port}`, 27 { rejectUnauthorized: false } 28 ); 29 client_stream = client.request({ ':method': 'POST' }); 30 client_stream.on('close', common.mustCall(() => { 31 client.close(); 32 server.close(); 33 })); 34 client_stream.resume(); 35 client_stream.write(Buffer.alloc(1024 * 1024)); 36}); 37