1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6const assert = require('assert');
7const http2 = require('http2');
8
9const http2Server = http2.createServer(common.mustCall(function(req, res) {
10  res.socket.on('finish', common.mustCall(() => {
11    assert(req.socket.bytesWritten > 0); // 1094
12  }));
13  res.writeHead(200, { 'Content-Type': 'text/plain' });
14  res.write(Buffer.from('1'.repeat(1024)));
15  res.end();
16}));
17
18http2Server.listen(0, common.mustCall(function() {
19  const URL = `http://localhost:${http2Server.address().port}`;
20  const http2client = http2.connect(URL, { protocol: 'http:' });
21  const req = http2client.request({ ':method': 'GET', ':path': '/' });
22  req.on('data', common.mustCall());
23  req.on('end', common.mustCall(function() {
24    http2client.close();
25    http2Server.close();
26  }));
27  req.end();
28}));
29