11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst http2 = require('http2'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst content = fixtures.readSync('person-large.jpg'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst server = http2.createServer({ 131cb0ef41Sopenharmony_ci maxSessionMemory: 1000 141cb0ef41Sopenharmony_ci}); 151cb0ef41Sopenharmony_ciserver.on('stream', (stream, headers) => { 161cb0ef41Sopenharmony_ci stream.respond({ 171cb0ef41Sopenharmony_ci 'content-type': 'image/jpeg', 181cb0ef41Sopenharmony_ci ':status': 200 191cb0ef41Sopenharmony_ci }); 201cb0ef41Sopenharmony_ci stream.end(content); 211cb0ef41Sopenharmony_ci}); 221cb0ef41Sopenharmony_ciserver.unref(); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 251cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${server.address().port}/`); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci let finished = 0; 281cb0ef41Sopenharmony_ci for (let i = 0; i < 100; i++) { 291cb0ef41Sopenharmony_ci const req = client.request({ ':path': '/' }).end(); 301cb0ef41Sopenharmony_ci const chunks = []; 311cb0ef41Sopenharmony_ci req.on('data', (chunk) => { 321cb0ef41Sopenharmony_ci chunks.push(chunk); 331cb0ef41Sopenharmony_ci }); 341cb0ef41Sopenharmony_ci req.on('end', common.mustCall(() => { 351cb0ef41Sopenharmony_ci assert.deepStrictEqual(Buffer.concat(chunks), content); 361cb0ef41Sopenharmony_ci if (++finished === 100) client.close(); 371cb0ef41Sopenharmony_ci })); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci})); 40