summaryrefslogtreecommitdiff
path: root/test/sequential/test-http2-large-file.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-10 14:28:26 -0700
committerGeorge Adams <george.adams@uk.ibm.com>2018-08-13 09:58:34 +0100
commitc29aff3ac7071a2d66206a3767fd946691c36c7f (patch)
tree732b18a0181b1a23724148f62fdb64ee5025b3ae /test/sequential/test-http2-large-file.js
parentac92a42a60545006a493e567c793601c6397c035 (diff)
downloadandroid-node-v8-c29aff3ac7071a2d66206a3767fd946691c36c7f.tar.gz
android-node-v8-c29aff3ac7071a2d66206a3767fd946691c36c7f.tar.bz2
android-node-v8-c29aff3ac7071a2d66206a3767fd946691c36c7f.zip
test: add test-http2-large-file sequential test
Refs: https://github.com/nodejs/node/issues/19141 PR-URL: https://github.com/nodejs/node/pull/22254 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: George Adams <george.adams@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/sequential/test-http2-large-file.js')
-rw-r--r--test/sequential/test-http2-large-file.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/sequential/test-http2-large-file.js b/test/sequential/test-http2-large-file.js
new file mode 100644
index 0000000000..d1a44e8d6b
--- /dev/null
+++ b/test/sequential/test-http2-large-file.js
@@ -0,0 +1,39 @@
+'use strict';
+
+// Test to ensure sending a large stream with a large initial window size works
+// See: https://github.com/nodejs/node/issues/19141
+
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+
+const http2 = require('http2');
+
+const server = http2.createServer({ settings: { initialWindowSize: 6553500 } });
+server.on('stream', (stream) => {
+ stream.resume();
+ stream.respond();
+ stream.end('ok');
+});
+
+server.listen(0, common.mustCall(() => {
+ let remaining = 1e8;
+ const chunk = 1e6;
+ 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);
+ } else {
+ request.end();
+ }
+ }
+ writeChunk();
+ request.on('close', common.mustCall(() => {
+ client.close();
+ server.close();
+ }));
+ request.resume();
+}));