Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3544,10 +3544,10 @@ properties.
permitted on the `Http2Session` instances. **Default:** `true`.
* `initialWindowSize` {number} Specifies the _sender's_ initial window size in
bytes for stream-level flow control. The minimum allowed value is 0. The
maximum allowed value is 2<sup>32</sup>-1. **Default:** `65535`.
maximum allowed value is 2<sup>32</sup>-1. **Default:** `262144`.
* `maxFrameSize` {number} Specifies the size in bytes of the largest frame
payload. The minimum allowed value is 16,384. The maximum allowed value is
2<sup>24</sup>-1. **Default:** `16384`.
2<sup>24</sup>-1. **Default:** `32768`.
* `maxConcurrentStreams` {number} Specifies the maximum number of concurrent
streams permitted on an `Http2Session`. There is no default value which
implies, at least theoretically, 2<sup>32</sup>-1 streams may be open
Expand Down
12 changes: 11 additions & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3302,14 +3302,18 @@ function connectionListener(socket) {

socket[kServer] = this;

// NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE default is 64KB, but we want to allow more data to be
// buffered without applying backpressure.
session.setLocalWindowSize(512 * 1024);

this.emit('session', session);
}

function initializeOptions(options) {
assertIsObject(options, 'options');
options = { ...options };
assertIsObject(options.settings, 'options.settings');
options.settings = { ...options.settings };
options.settings = { ...getDefaultSettings(), ...options.settings };

assertIsArray(options.remoteCustomSettings, 'options.remoteCustomSettings');
if (options.remoteCustomSettings) {
Expand Down Expand Up @@ -3531,6 +3535,8 @@ function connect(authority, options, listener) {

assertIsObject(options, 'options');
options = { ...options };
assertIsObject(options.settings, 'options.settings');
options.settings = { ...getDefaultSettings(), ...options.settings };

assertIsArray(options.remoteCustomSettings, 'options.remoteCustomSettings');
if (options.remoteCustomSettings) {
Expand Down Expand Up @@ -3576,6 +3582,10 @@ function connect(authority, options, listener) {

const session = new ClientHttp2Session(options, socket);

// NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE default is 64KB, but we want to allow more data to be
// buffered without applying backpressure.
session.setLocalWindowSize(512 * 1024);

session[kAuthority] = `${options.servername || host}:${port}`;
session[kProtocol] = protocol;

Expand Down
7 changes: 7 additions & 0 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ function getDefaultSettings() {
settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL] === 1;
}

// NGHTTP2_INITIAL_WINDOW_SIZE default is 64KB, but we want to allow more data to be
// buffered without applying backpressure.
holder.initialWindowSize = MathMax(holder.initialWindowSize, 256 * 1024);

// Default is 16KB.
holder.maxFrameSize = MathMax(32 * 1024, holder.maxFrameSize);

if (settingsBuffer[IDX_SETTINGS_FLAGS + 1]) holder.customSettings = addCustomSettingsToObj();

return holder;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const settings = http2.getDefaultSettings();
assert.strictEqual(settings.headerTableSize, 4096);
assert.strictEqual(settings.enablePush, true);
assert.strictEqual(settings.maxConcurrentStreams, 4294967295);
assert.strictEqual(settings.initialWindowSize, 65535);
assert.strictEqual(settings.maxFrameSize, 16384);
assert.strictEqual(settings.initialWindowSize, 256 * 1024);
assert.strictEqual(settings.maxFrameSize, 32 * 1024);

assert.strictEqual(binding.nghttp2ErrorString(-517),
'GOAWAY has already been sent');
Expand Down
Loading