Skip to content

Commit dc57d4e

Browse files
jasnellrvagg
authored andcommitted
test: add test-http2-large-file sequential test
Refs: #19141 PR-URL: #22254 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: George Adams <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 83373e2 commit dc57d4e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
// Test to ensure sending a large stream with a large initial window size works
4+
// See: https://github.com/nodejs/node/issues/19141
5+
6+
constcommon=require('../common');
7+
if(!common.hasCrypto)
8+
common.skip('missing crypto');
9+
10+
consthttp2=require('http2');
11+
12+
constserver=http2.createServer({settings: {initialWindowSize: 6553500}});
13+
server.on('stream',(stream)=>{
14+
stream.resume();
15+
stream.respond();
16+
stream.end('ok');
17+
});
18+
19+
server.listen(0,common.mustCall(()=>{
20+
letremaining=1e8;
21+
constchunk=1e6;
22+
constclient=http2.connect(`http://localhost:${server.address().port}`,
23+
{settings: {initialWindowSize: 6553500}});
24+
constrequest=client.request({':method': 'POST'});
25+
functionwriteChunk(){
26+
if(remaining>0){
27+
remaining-=chunk;
28+
request.write(Buffer.alloc(chunk,'a'),writeChunk);
29+
}else{
30+
request.end();
31+
}
32+
}
33+
writeChunk();
34+
request.on('close',common.mustCall(()=>{
35+
client.close();
36+
server.close();
37+
}));
38+
request.resume();
39+
}));

0 commit comments

Comments
(0)