http2: remove side effects from validateSettings · nodejs/node@ce26590 (original) (raw)

`@@ -784,7 +784,7 @@ function pingCallback(cb) {

`

784

784

`// 6. enablePush must be a boolean

`

785

785

`// All settings are optional and may be left undefined

`

786

786

`const validateSettings = hideStackFrames((settings) => {

`

787

``

`-

settings = { ...settings };

`

``

787

`+

if (settings === undefined) return;

`

788

788

`assertWithinRange('headerTableSize',

`

789

789

`settings.headerTableSize,

`

790

790

`0, kMaxInt);

`

`@@ -805,7 +805,6 @@ const validateSettings = hideStackFrames((settings) => {

`

805

805

`throw new ERR_HTTP2_INVALID_SETTING_VALUE('enablePush',

`

806

806

`settings.enablePush);

`

807

807

`}

`

808

``

`-

return settings;

`

809

808

`});

`

810

809

``

811

810

`// Creates the internal binding.Http2Session handle for an Http2Session

`

`@@ -1144,15 +1143,15 @@ class Http2Session extends EventEmitter {

`

1144

1143

`if (this.destroyed)

`

1145

1144

`throw new ERR_HTTP2_INVALID_SESSION();

`

1146

1145

`assertIsObject(settings, 'settings');

`

1147

``

`-

settings = validateSettings(settings);

`

``

1146

`+

validateSettings(settings);

`

1148

1147

``

1149

1148

`if (callback && typeof callback !== 'function')

`

1150

1149

`throw new ERR_INVALID_CALLBACK();

`

1151

1150

`` debug(Http2Session ${sessionName(this[kType])}: sending settings);

``

1152

1151

``

1153

1152

`this[kState].pendingAck++;

`

1154

1153

``

1155

``

`-

const settingsFn = submitSettings.bind(this, settings, callback);

`

``

1154

`+

const settingsFn = submitSettings.bind(this, { ...settings }, callback);

`

1156

1155

`if (this.connecting) {

`

1157

1156

`this.once('connect', settingsFn);

`

1158

1157

`return;

`

`@@ -2817,7 +2816,8 @@ function createServer(options, handler) {

`

2817

2816

`// HTTP2-Settings header frame.

`

2818

2817

`function getPackedSettings(settings) {

`

2819

2818

`assertIsObject(settings, 'settings');

`

2820

``

`-

updateSettingsBuffer(validateSettings(settings));

`

``

2819

`+

validateSettings(settings);

`

``

2820

`+

updateSettingsBuffer({ ...settings });

`

2821

2821

`return binding.packSettings();

`

2822

2822

`}

`

2823

2823

``