1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5 6const fixtures = require('../common/fixtures'); 7const assert = require('assert'); 8const http2 = require('http2'); 9 10const content = fixtures.readSync('person-large.jpg'); 11 12const server = http2.createServer({ 13 maxSessionMemory: 1000 14}); 15server.on('stream', (stream, headers) => { 16 stream.respond({ 17 'content-type': 'image/jpeg', 18 ':status': 200 19 }); 20 stream.end(content); 21}); 22server.unref(); 23 24server.listen(0, common.mustCall(() => { 25 const client = http2.connect(`http://localhost:${server.address().port}/`); 26 27 let finished = 0; 28 for (let i = 0; i < 100; i++) { 29 const req = client.request({ ':path': '/' }).end(); 30 const chunks = []; 31 req.on('data', (chunk) => { 32 chunks.push(chunk); 33 }); 34 req.on('end', common.mustCall(() => { 35 assert.deepStrictEqual(Buffer.concat(chunks), content); 36 if (++finished === 100) client.close(); 37 })); 38 } 39})); 40