Skip to content

Commit

Permalink
test: optimize test-http2-large-file
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Trott authored and MylesBorins committed May 16, 2019
1 parent ddfa756 commit 44660c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/sequential/test-http2-large-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

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

const common = require('../common');
Expand All @@ -18,14 +18,15 @@ server.on('stream', (stream) => {

server.listen(0, common.mustCall(() => {
let remaining = 1e8;
const chunk = 1e6;
const chunkLength = 1e6;
const chunk = Buffer.alloc(chunkLength, 'a');
const client = http2.connect(`http://localhost:${server.address().port}`,
{ settings: { initialWindowSize: 6553500 } });
const request = client.request({ ':method': 'POST' });
function writeChunk() {
if (remaining > 0) {
remaining -= chunk;
request.write(Buffer.alloc(chunk, 'a'), writeChunk);
remaining -= chunkLength;
request.write(chunk, writeChunk);
} else {
request.end();
}
Expand Down

0 comments on commit 44660c1

Please sign in to comment.