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 stream.on('error', () => {}); 24})); 25 26server.listen(0, function() { 27 const client = http2.connect(`https://localhost:${server.address().port}`, 28 { rejectUnauthorized: false } 29 ); 30 client_stream = client.request({ ':method': 'POST' }); 31 client_stream.on('close', common.mustCall(() => { 32 client.close(); 33 server.close(); 34 })); 35 client_stream.resume(); 36 client_stream.write(Buffer.alloc(1024 * 1024)); 37}); 38