Skip to content

Commit 66dbaff

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 <jasnell@gmail.com>
1 parent 631e433 commit 66dbaff

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
if(!common.hasCrypto)
5+
common.skip('missing crypto');
6+
constassert=require('assert');
7+
consthttp2=require('http2');
8+
9+
consthttp2Server=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+
constURL=`http://localhost:${http2Server.address().port}`;
20+
consthttp2client=http2.connect(URL,{protocol: 'http:'});
21+
constreq=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)