GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: correct behaviour for enablePush unpack · nodejs/node@2e421ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/http2
    • core.js
  • test/parallel
    • test-http2-getpackedsettings.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,7 @@ function getUnpackedSettings(buf, options = {}) {
25352535
settings.headerTableSize = value;
25362536
break;
25372537
case NGHTTP2_SETTINGS_ENABLE_PUSH:
2538-
settings.enablePush = Boolean(value);
2538+
settings.enablePush = value;
25392539
break;
25402540
case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
25412541
settings.maxConcurrentStreams = value;
@@ -2557,6 +2557,9 @@ function getUnpackedSettings(buf, options = {}) {
25572557
assertWithinRange('headerTableSize',
25582558
settings.headerTableSize,
25592559
0, 2 ** 32 - 1);
2560+
assertWithinRange('enablePush',
2561+
settings.enablePush,
2562+
0, 1);
25602563
assertWithinRange('initialWindowSize',
25612564
settings.initialWindowSize,
25622565
0, 2 ** 32 - 1);
@@ -2569,13 +2572,10 @@ function getUnpackedSettings(buf, options = {}) {
25692572
assertWithinRange('maxHeaderListSize',
25702573
settings.maxHeaderListSize,
25712574
0, 2 ** 32 - 1);
2572-
if (settings.enablePush !== undefined &&
2573-
typeof settings.enablePush !== 'boolean') {
2574-
const err = new errors.TypeError('ERR_HTTP2_INVALID_SETTING_VALUE',
2575-
'enablePush', settings.enablePush);
2576-
err.actual = settings.enablePush;
2577-
throw err;
2578-
}
2575+
}
2576+
2577+
if (settings.enablePush !== undefined) {
2578+
settings.enablePush = !!settings.enablePush;
25792579
}
25802580

25812581
return settings;
Collapse file

‎test/parallel/test-http2-getpackedsettings.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-getpackedsettings.js
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
126126
assert.strictEqual(settings.enablePush, true);
127127
}
128128

129+
//should throw if enablePush is not 0 or 1
130+
{
131+
const packed = Buffer.from([
132+
0x00, 0x02, 0x00, 0x00, 0x00, 0x00]);
133+
134+
const settings = http2.getUnpackedSettings(packed, { validate: true });
135+
assert.strictEqual(settings.enablePush, false);
136+
}
137+
{
138+
const packed = Buffer.from([
139+
0x00, 0x02, 0x00, 0x00, 0x00, 0x64]);
140+
141+
assert.throws(() => {
142+
http2.getUnpackedSettings(packed, { validate: true });
143+
}, common.expectsError({
144+
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
145+
type: RangeError,
146+
message: 'Invalid value for setting "enablePush": 100'
147+
}));
148+
}
149+
129150
//check for what happens if passing {validate: true} and no errors happen
130151
{
131152
const packed = Buffer.from([

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.