From 9f3d59eabb6564ad337a762d61ac767f9130e8a5 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 1 Nov 2017 11:48:11 -0700 Subject: 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 Reviewed-By: Anna Henningsen --- src/node_http2.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/node_http2.h') diff --git a/src/node_http2.h b/src/node_http2.h index a19e032cce..9454301ec4 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -292,14 +292,6 @@ const char* nghttp2_errname(int rv) { } } -#define DEFAULT_SETTINGS_HEADER_TABLE_SIZE 4096 -#define DEFAULT_SETTINGS_ENABLE_PUSH 1 -#define DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE 65535 -#define DEFAULT_SETTINGS_MAX_FRAME_SIZE 16384 -#define MAX_MAX_FRAME_SIZE 16777215 -#define MIN_MAX_FRAME_SIZE DEFAULT_SETTINGS_MAX_FRAME_SIZE -#define MAX_INITIAL_WINDOW_SIZE 2147483647 - // This allows for 4 default-sized frames with their frame headers static const size_t kAllocBufferSize = 4 * (16384 + 9); @@ -324,19 +316,25 @@ class Http2Options { return options_; } + void SetMaxHeaderPairs(uint32_t max) { + max_header_pairs_ = max; + } + + uint32_t GetMaxHeaderPairs() const { + return max_header_pairs_; + } + void SetPaddingStrategy(padding_strategy_type val) { -#if DEBUG - CHECK_LE(val, PADDING_STRATEGY_CALLBACK); -#endif padding_strategy_ = static_cast(val); } - padding_strategy_type GetPaddingStrategy() { + padding_strategy_type GetPaddingStrategy() const { return padding_strategy_; } private: nghttp2_option* options_; + uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS; padding_strategy_type padding_strategy_ = PADDING_STRATEGY_NONE; }; @@ -413,7 +411,8 @@ class Http2Session : public AsyncWrap, void OnHeaders( Nghttp2Stream* stream, - std::queue* headers, + nghttp2_header* headers, + size_t count, nghttp2_headers_category cat, uint8_t flags) override; void OnStreamClose(int32_t id, uint32_t code) override; -- cgit v1.2.3