summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-08-11 02:22:00 +0200
committerMichaƫl Zasso <targos@protonmail.com>2019-08-15 09:51:53 +0200
commit8a4a1931b8b98242abb590936c31f0c20dd2e08f (patch)
treec8bf3c88ae02fc925d8005559d46a45b1e0e477d /test
parentba624b6766fffc11fc9a387feee58be2c5e1d8b8 (diff)
downloadandroid-node-v8-8a4a1931b8b98242abb590936c31f0c20dd2e08f.tar.gz
android-node-v8-8a4a1931b8b98242abb590936c31f0c20dd2e08f.tar.bz2
android-node-v8-8a4a1931b8b98242abb590936c31f0c20dd2e08f.zip
http2: pause input processing if sending output
If we are waiting for the ability to send more output, we should not process more input. This commit a) makes us send output earlier, during processing of input, if we accumulate a lot and b) allows interrupting the call into nghttp2 that processes input data and resuming it at a later time, if we do find ourselves in a position where we are waiting to be able to send more output. This is part of mitigating CVE-2019-9511/CVE-2019-9517. PR-URL: https://github.com/nodejs/node/pull/29122 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http2-large-write-multiple-requests.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/parallel/test-http2-large-write-multiple-requests.js b/test/parallel/test-http2-large-write-multiple-requests.js
new file mode 100644
index 0000000000..0d65c3479b
--- /dev/null
+++ b/test/parallel/test-http2-large-write-multiple-requests.js
@@ -0,0 +1,39 @@
+'use strict';
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+
+const fixtures = require('../common/fixtures');
+const assert = require('assert');
+const http2 = require('http2');
+
+const content = fixtures.readSync('person-large.jpg');
+
+const server = http2.createServer({
+ maxSessionMemory: 1000
+});
+server.on('stream', (stream, headers) => {
+ stream.respond({
+ 'content-type': 'image/jpeg',
+ ':status': 200
+ });
+ stream.end(content);
+});
+server.unref();
+
+server.listen(0, common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${server.address().port}/`);
+
+ let finished = 0;
+ for (let i = 0; i < 100; i++) {
+ const req = client.request({ ':path': '/' }).end();
+ const chunks = [];
+ req.on('data', (chunk) => {
+ chunks.push(chunk);
+ });
+ req.on('end', common.mustCall(() => {
+ assert.deepStrictEqual(Buffer.concat(chunks), content);
+ if (++finished === 100) client.close();
+ }));
+ }
+}));