8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 781ffd8 commit 914db60Copy full SHA for 914db60
doc/api/http2.md
@@ -2766,6 +2766,10 @@ Throws `ERR_INVALID_ARG_TYPE` for invalid `settings` argument.
2766
<!-- YAML
2767
added: v8.4.0
2768
changes:
2769
+ - version:
2770
+ - REPLACEME
2771
+ pr-url: https://github.com/nodejs/node/pull/54875
2772
+ description: Added `streamResetBurst` and `streamResetRate`.
2773
- version:
2774
- v15.10.0
2775
- v14.16.0
@@ -2868,6 +2872,9 @@ changes:
2868
2872
**Default:** `100`.
2869
2873
* `settings` {HTTP/2 Settings Object} The initial settings to send to the
2870
2874
remote peer upon connection.
2875
+ * `streamResetBurst` {number} and `streamResetRate` {number} Sets the rate
2876
+ limit for the incoming stream reset (RST\_STREAM frame). Both settings must
2877
+ be set to have any effect, and default to 1000 and 33 respectively.
2871
2878
* `remoteCustomSettings` {Array} The array of integer values determines the
2879
settings types, which are included in the `CustomSettings`-property of
2880
the received remoteSettings. Please see the `CustomSettings`-property of
lib/internal/http2/util.js
@@ -216,7 +216,9 @@ const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
216
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
217
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
218
const IDX_OPTIONS_MAX_SETTINGS = 9;
219
-const IDX_OPTIONS_FLAGS = 10;
+const IDX_OPTIONS_STREAM_RESET_RATE = 10;
220
+const IDX_OPTIONS_STREAM_RESET_BURST = 11;
221
+const IDX_OPTIONS_FLAGS = 12;
222
223
function updateOptionsBuffer(options) {
224
let flags = 0;
@@ -270,6 +272,16 @@ function updateOptionsBuffer(options) {
270
272
optionsBuffer[IDX_OPTIONS_MAX_SETTINGS] =
271
273
MathMax(1, options.maxSettings);
274
}
275
+ if (typeof options.streamResetRate === 'number') {
276
+ flags |= (1 << IDX_OPTIONS_STREAM_RESET_RATE);
277
+ optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE] =
278
+ MathMax(1, options.streamResetRate);
279
+ }
280
+ if (typeof options.streamResetBurst === 'number') {
281
+ flags |= (1 << IDX_OPTIONS_STREAM_RESET_BURST);
282
+ optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST] =
283
+ MathMax(1, options.streamResetBurst);
284
285
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
286
287
src/node_http2.cc
@@ -208,6 +208,14 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) {
208
option,
209
static_cast<size_t>(buffer[IDX_OPTIONS_MAX_SETTINGS]));
210
211
+
212
+ if ((flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST)) &&
213
+ (flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE))) {
214
+ nghttp2_option_set_stream_reset_rate_limit(
215
+ option,
+ static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_BURST]),
+ static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_RATE]));
#define GRABSETTING(entries, count, name) \
src/node_http2_state.h
@@ -58,6 +58,8 @@ namespace http2 {
58
IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS,
59
IDX_OPTIONS_MAX_SESSION_MEMORY,
60
IDX_OPTIONS_MAX_SETTINGS,
61
+ IDX_OPTIONS_STREAM_RESET_RATE,
62
+ IDX_OPTIONS_STREAM_RESET_BURST,
63
IDX_OPTIONS_FLAGS
64
};
65
test/parallel/test-http2-util-update-options-buffer.js
@@ -23,7 +23,9 @@ const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
23
24
25
26
27
28
29
30
{
31
updateOptionsBuffer({
@@ -37,6 +39,8 @@ const IDX_OPTIONS_FLAGS = 10;
37
39
maxOutstandingSettings: 8,
38
40
maxSessionMemory: 9,
41
maxSettings: 10,
42
+ streamResetRate: 11,
43
+ streamResetBurst: 12,
44
});
45
46
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1);
@@ -49,6 +53,8 @@ const IDX_OPTIONS_FLAGS = 10;
49
53
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS], 8);
50
54
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY], 9);
51
55
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10);
56
+ strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE], 11);
57
+ strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST], 12);
52
const flags = optionsBuffer[IDX_OPTIONS_FLAGS];
@@ -61,6 +67,8 @@ const IDX_OPTIONS_FLAGS = 10;
67
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS));
68
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS));
69
ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS));
70
+ ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE));
71
+ ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST));
72
73
66
74