summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-too-many-headers.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-11-01 11:48:11 -0700
committerJames M Snell <jasnell@gmail.com>2017-11-04 22:32:44 -0700
commit9f3d59eabb6564ad337a762d61ac767f9130e8a5 (patch)
treea0fdb43c530be18d6ed5dded16378c6f30d91da6 /test/parallel/test-http2-too-many-headers.js
parent1f045f491a6a8d6ac193474f3856e2bdbd6847be (diff)
downloadandroid-node-v8-9f3d59eabb6564ad337a762d61ac767f9130e8a5.tar.gz
android-node-v8-9f3d59eabb6564ad337a762d61ac767f9130e8a5.tar.bz2
android-node-v8-9f3d59eabb6564ad337a762d61ac767f9130e8a5.zip
http2: refactor multiple internals
* eliminate pooling of Nghttp2Stream instances. After testing, the pooling is not having any tangible benefit and makes things more complicated. Simplify. Simplify. * refactor inbound headers * Enforce MAX_HEADERS_LIST setting and limit the number of header pairs accepted from the peer. Use the ENHANCE_YOUR_CALM error code when receiving either too many headers or too many octets. Use a vector to store the headers instead of a queue PR-URL: https://github.com/nodejs/node/pull/16676 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-http2-too-many-headers.js')
-rw-r--r--test/parallel/test-http2-too-many-headers.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/parallel/test-http2-too-many-headers.js b/test/parallel/test-http2-too-many-headers.js
new file mode 100644
index 0000000000..3d63727ed5
--- /dev/null
+++ b/test/parallel/test-http2-too-many-headers.js
@@ -0,0 +1,34 @@
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const http2 = require('http2');
+const assert = require('assert');
+const {
+ NGHTTP2_ENHANCE_YOUR_CALM
+} = http2.constants;
+
+// By default, the maximum number of header fields allowed per
+// block is 128, including the HTTP pseudo-header fields. The
+// minimum value for servers is 4, setting this to any value
+// less than 4 will still leave the minimum to 4.
+const server = http2.createServer({ maxHeaderListPairs: 0 });
+server.on('stream', common.mustNotCall());
+
+server.listen(0, common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${server.address().port}`);
+
+ const req = client.request({ foo: 'bar' });
+ req.on('error', common.expectsError({
+ code: 'ERR_HTTP2_STREAM_ERROR',
+ type: Error,
+ message: 'Stream closed with error code 11'
+ }));
+ req.on('streamClosed', common.mustCall((code) => {
+ assert.strictEqual(code, NGHTTP2_ENHANCE_YOUR_CALM);
+ server.close();
+ client.destroy();
+ }));
+
+}));