diff options
author | Rich Trott <rtrott@gmail.com> | 2019-03-18 05:55:43 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-03-20 09:50:52 -0700 |
commit | ba1c5fffaf3f681ed061d253665814bb0178f76d (patch) | |
tree | 0645861e3ae801a21e24bb8dbd06b5a929763cfd /test/sequential/test-http2-large-file.js | |
parent | 42dbaed4605f44c393a057aad75a31cac1d0e5f5 (diff) | |
download | android-node-v8-ba1c5fffaf3f681ed061d253665814bb0178f76d.tar.gz android-node-v8-ba1c5fffaf3f681ed061d253665814bb0178f76d.tar.bz2 android-node-v8-ba1c5fffaf3f681ed061d253665814bb0178f76d.zip |
test: optimize test-http2-large-file
Optimize test-http2-large-file so it only allocates a single buffer.
PR-URL: https://github.com/nodejs/node/pull/26737
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Adrian Estrada <edsadr@gmail.com>
Diffstat (limited to 'test/sequential/test-http2-large-file.js')
-rw-r--r-- | test/sequential/test-http2-large-file.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/sequential/test-http2-large-file.js b/test/sequential/test-http2-large-file.js index d1a44e8d6b..2f2cc2c80d 100644 --- a/test/sequential/test-http2-large-file.js +++ b/test/sequential/test-http2-large-file.js @@ -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'); @@ -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(); } |