1'use strict'; 2 3// Test sending a large stream with a large initial window size. 4// See: https://github.com/nodejs/node/issues/19141 5 6const common = require('../common'); 7if (!common.hasCrypto) 8 common.skip('missing crypto'); 9 10const http2 = require('http2'); 11 12const server = http2.createServer({ settings: { initialWindowSize: 6553500 } }); 13server.on('stream', (stream) => { 14 stream.resume(); 15 stream.respond(); 16 stream.end('ok'); 17}); 18 19server.listen(0, common.mustCall(() => { 20 let remaining = 1e8; 21 const chunkLength = 1e6; 22 const chunk = Buffer.alloc(chunkLength, 'a'); 23 const client = http2.connect(`http://localhost:${server.address().port}`, 24 { settings: { initialWindowSize: 6553500 } }); 25 const request = client.request({ ':method': 'POST' }); 26 function writeChunk() { 27 if (remaining > 0) { 28 remaining -= chunkLength; 29 request.write(chunk, writeChunk); 30 } else { 31 request.end(); 32 } 33 } 34 writeChunk(); 35 request.on('close', common.mustCall(() => { 36 client.close(); 37 server.close(); 38 })); 39 request.resume(); 40})); 41