Skip to content

Commit 7ebd6bd

Browse files
Trotttargos
authored andcommittedMar 27, 2019
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 <matteo.collina@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com>
1 parent 5b8eae4 commit 7ebd6bd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

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

+5-4
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
const common = require('../common');
@@ -18,14 +18,15 @@ server.on('stream', (stream) => {
1818

1919
server.listen(0, common.mustCall(() => {
2020
let remaining = 1e8;
21-
const chunk = 1e6;
21+
const chunkLength = 1e6;
22+
const chunk = Buffer.alloc(chunkLength, 'a');
2223
const client = http2.connect(`http://localhost:${server.address().port}`,
2324
{ settings: { initialWindowSize: 6553500 } });
2425
const request = client.request({ ':method': 'POST' });
2526
function writeChunk() {
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)