Skip to content

Commit 44660c1

Browse files
TrottMylesBorins
authored andcommitted
test: optimize test-http2-large-file
Optimize test-http2-large-file so it only allocates a single buffer. PR-URL: #26737 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Adrian Estrada <[email protected]>
1 parent ddfa756 commit 44660c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎test/sequential/test-http2-large-file.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
// Test to ensure sending a large stream with a large initial window size works
3+
// Test sending a large stream with a large initial window size.
44
// See: https://github.com/nodejs/node/issues/19141
55

66
constcommon=require('../common');
@@ -18,14 +18,15 @@ server.on('stream', (stream) =>{
1818

1919
server.listen(0,common.mustCall(()=>{
2020
letremaining=1e8;
21-
constchunk=1e6;
21+
constchunkLength=1e6;
22+
constchunk=Buffer.alloc(chunkLength,'a');
2223
constclient=http2.connect(`http://localhost:${server.address().port}`,
2324
{settings: {initialWindowSize: 6553500}});
2425
constrequest=client.request({':method': 'POST'});
2526
functionwriteChunk(){
2627
if(remaining>0){
27-
remaining-=chunk;
28-
request.write(Buffer.alloc(chunk,'a'),writeChunk);
28+
remaining-=chunkLength;
29+
request.write(chunk,writeChunk);
2930
}else{
3031
request.end();
3132
}

0 commit comments

Comments
(0)