diff --git a/doc/api/http2.md b/doc/api/http2.md
index 3f7ca83fcc222b..ac273b9fa44cb5 100644
--- a/doc/api/http2.md
+++ b/doc/api/http2.md
@@ -2420,7 +2420,7 @@ properties.
header compression. The minimum allowed value is 0. The maximum allowed value
is 232-1. **Default:** `4,096 octets`.
* `enablePush` {boolean} Specifies `true` if HTTP/2 Push Streams are to be
- permitted on the `Http2Session` instances.
+ permitted on the `Http2Session` instances. **Default:** `true`.
* `initialWindowSize` {number} Specifies the *senders* initial window size
for stream-level flow control. The minimum allowed value is 0. The maximum
allowed value is 232-1. **Default:** `65,535 bytes`.
@@ -2440,6 +2440,7 @@ properties.
Protocol" defined by [RFC 8441][] is to be enabled. This setting is only
meaningful if sent by the server. Once the `enableConnectProtocol` setting
has been enabled for a given `Http2Session`, it cannot be disabled.
+ **Default:** `false`.
All additional properties on the settings object are ignored.
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 3e43a7e565500b..056a81fbe26f4e 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -261,6 +261,7 @@ const {
NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
NGHTTP2_SETTINGS_MAX_FRAME_SIZE,
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
+ NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL,
HTTP2_METHOD_GET,
HTTP2_METHOD_HEAD,
@@ -908,6 +909,7 @@ function pingCallback(cb) {
// 4. maxConcurrentStreams must be a number in the range 0 <= n <= kMaxStreams
// 5. maxHeaderListSize must be a number in the range 0 <= n <= kMaxInt
// 6. enablePush must be a boolean
+// 7. enableConnectProtocol must be a boolean
// All settings are optional and may be left undefined
const validateSettings = hideStackFrames((settings) => {
if (settings === undefined) return;
@@ -931,6 +933,11 @@ const validateSettings = hideStackFrames((settings) => {
throw new ERR_HTTP2_INVALID_SETTING_VALUE('enablePush',
settings.enablePush);
}
+ if (settings.enableConnectProtocol !== undefined &&
+ typeof settings.enableConnectProtocol !== 'boolean') {
+ throw new ERR_HTTP2_INVALID_SETTING_VALUE('enableConnectProtocol',
+ settings.enableConnectProtocol);
+ }
});
// Creates the internal binding.Http2Session handle for an Http2Session
@@ -3127,6 +3134,8 @@ function getUnpackedSettings(buf, options = {}) {
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
settings.maxHeaderListSize = value;
break;
+ case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
+ settings.enableConnectProtocol = value !== 0;
}
offset += 4;
}
diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js
index ba2526177a133d..3c9b35bb774960 100644
--- a/lib/internal/http2/util.js
+++ b/lib/internal/http2/util.js
@@ -301,7 +301,7 @@ function getDefaultSettings() {
if ((flags & (1 << IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL)) ===
(1 << IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL)) {
holder.enableConnectProtocol =
- settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL];
+ settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL] === 1;
}
return holder;
@@ -322,7 +322,8 @@ function getSettings(session, remote) {
maxFrameSize: settingsBuffer[IDX_SETTINGS_MAX_FRAME_SIZE],
maxConcurrentStreams: settingsBuffer[IDX_SETTINGS_MAX_CONCURRENT_STREAMS],
maxHeaderListSize: settingsBuffer[IDX_SETTINGS_MAX_HEADER_LIST_SIZE],
- enableConnectProtocol: settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL]
+ enableConnectProtocol:
+ !!settingsBuffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL]
};
}
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 6dded8325652c5..9c649a7ac592c1 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -301,13 +301,16 @@ void Http2Session::Http2Settings::RefreshDefaults(Environment* env) {
DEFAULT_SETTINGS_MAX_FRAME_SIZE;
buffer[IDX_SETTINGS_MAX_HEADER_LIST_SIZE] =
DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE;
+ buffer[IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL] =
+ DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL;
buffer[IDX_SETTINGS_COUNT] =
(1 << IDX_SETTINGS_HEADER_TABLE_SIZE) |
(1 << IDX_SETTINGS_ENABLE_PUSH) |
(1 << IDX_SETTINGS_MAX_CONCURRENT_STREAMS) |
(1 << IDX_SETTINGS_INITIAL_WINDOW_SIZE) |
(1 << IDX_SETTINGS_MAX_FRAME_SIZE) |
- (1 << IDX_SETTINGS_MAX_HEADER_LIST_SIZE);
+ (1 << IDX_SETTINGS_MAX_HEADER_LIST_SIZE) |
+ (1 << IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL);
}
@@ -3183,6 +3186,8 @@ void Initialize(Local