11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/33156
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciif (!common.hasCrypto) {
71cb0ef41Sopenharmony_ci  common.skip('missing crypto');
81cb0ef41Sopenharmony_ci}
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst http2 = require('http2');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst key = fixtures.readKey('agent8-key.pem', 'binary');
131cb0ef41Sopenharmony_ciconst cert = fixtures.readKey('agent8-cert.pem', 'binary');
141cb0ef41Sopenharmony_ciconst ca = fixtures.readKey('fake-startcom-root-cert.pem', 'binary');
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst server = http2.createSecureServer({
171cb0ef41Sopenharmony_ci  key,
181cb0ef41Sopenharmony_ci  cert,
191cb0ef41Sopenharmony_ci  maxSessionMemory: 1000
201cb0ef41Sopenharmony_ci});
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cilet client_stream;
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciserver.on('session', common.mustCall(function(session) {
251cb0ef41Sopenharmony_ci  session.on('stream', common.mustCall(function(stream) {
261cb0ef41Sopenharmony_ci    stream.resume();
271cb0ef41Sopenharmony_ci    stream.on('data', function() {
281cb0ef41Sopenharmony_ci      this.write(Buffer.alloc(1));
291cb0ef41Sopenharmony_ci      process.nextTick(() => client_stream.destroy());
301cb0ef41Sopenharmony_ci    });
311cb0ef41Sopenharmony_ci  }));
321cb0ef41Sopenharmony_ci}));
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciserver.listen(0, function() {
351cb0ef41Sopenharmony_ci  const client = http2.connect(`https://localhost:${server.address().port}`, {
361cb0ef41Sopenharmony_ci    ca,
371cb0ef41Sopenharmony_ci    maxSessionMemory: 1000
381cb0ef41Sopenharmony_ci  });
391cb0ef41Sopenharmony_ci  client_stream = client.request({ ':method': 'POST' });
401cb0ef41Sopenharmony_ci  client_stream.on('close', common.mustCall(() => {
411cb0ef41Sopenharmony_ci    client.close();
421cb0ef41Sopenharmony_ci    server.close();
431cb0ef41Sopenharmony_ci  }));
441cb0ef41Sopenharmony_ci  client_stream.resume();
451cb0ef41Sopenharmony_ci  client_stream.write(Buffer.alloc(64 * 1024));
461cb0ef41Sopenharmony_ci});
47