Skip to content

Commit 41c5524

Browse files
rexagodcodebytere
authored andcommitted
http2: add bytesWritten test for Http2Stream
note that this is for the `Http2Server` class. I'll soon be adding one for `Http2SecureServer` as well. Refs: #29829 PR-URL: #33162 Reviewed-By: James M Snell <[email protected]>
1 parent b634d4b commit 41c5524

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const assert = require('assert');
7+
const http2 = require('http2');
8+
9+
const 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+
18+
http2Server.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+
}));

0 commit comments

Comments
 (0)