| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 55b7a6c commit 883ed4b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1879,6 +1879,19 @@ A value of `0` will disable the timeout behavior on incoming connections. | |||
| 1879 | 1879 | The socket timeout logic is set up on connection, so changing this | |
| 1880 | 1880 | value only affects new connections to the server, not any existing connections. | |
| 1881 | 1881 | ||
| 1882 | + #### `server.updateSettings([settings])` | ||
| 1883 | + <!-- YAML | ||
| 1884 | + added: REPLACEME | ||
| 1885 | + --> | ||
| 1886 | + | ||
| 1887 | + * `settings` {HTTP/2 Settings Object} | ||
| 1888 | + | ||
| 1889 | + Used to update the server with the provided settings. | ||
| 1890 | + | ||
| 1891 | + Throws `ERR_HTTP2_INVALID_SETTING_VALUE` for invalid `settings` values. | ||
| 1892 | + | ||
| 1893 | + Throws `ERR_INVALID_ARG_TYPE` for invalid `settings` argument. | ||
| 1894 | + | ||
| 1882 | 1895 | ### Class: `Http2SecureServer` | |
| 1883 | 1896 | <!-- YAML | |
| 1884 | 1897 | added: v8.4.0 | |
@@ -2058,6 +2071,19 @@ A value of `0` will disable the timeout behavior on incoming connections. | |||
| 2058 | 2071 | The socket timeout logic is set up on connection, so changing this | |
| 2059 | 2072 | value only affects new connections to the server, not any existing connections. | |
| 2060 | 2073 | ||
| 2074 | + #### `server.updateSettings([settings])` | ||
| 2075 | + <!-- YAML | ||
| 2076 | + added: REPLACEME | ||
| 2077 | + --> | ||
| 2078 | + | ||
| 2079 | + * `settings` {HTTP/2 Settings Object} | ||
| 2080 | + | ||
| 2081 | + Used to update the server with the provided settings. | ||
| 2082 | + | ||
| 2083 | + Throws `ERR_HTTP2_INVALID_SETTING_VALUE` for invalid `settings` values. | ||
| 2084 | + | ||
| 2085 | + Throws `ERR_INVALID_ARG_TYPE` for invalid `settings` argument. | ||
| 2086 | + | ||
| 2061 | 2087 | ### `http2.createServer(options[, onRequestHandler])` | |
| 2062 | 2088 | <!-- YAML | |
| 2063 | 2089 | added: v8.4.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2992,6 +2992,12 @@ class Http2SecureServer extends TLSServer { | |||
| 2992 | 2992 | } | |
| 2993 | 2993 | return this; | |
| 2994 | 2994 | } | |
| 2995 | + | ||
| 2996 | + updateSettings(settings) { | ||
| 2997 | + assertIsObject(settings, 'settings'); | ||
| 2998 | + validateSettings(settings); | ||
| 2999 | + this[kOptions].settings = { ...this[kOptions].settings, ...settings }; | ||
| 3000 | + } | ||
| 2995 | 3001 | } | |
| 2996 | 3002 | ||
| 2997 | 3003 | class Http2Server extends NETServer { | |
@@ -3014,6 +3020,12 @@ class Http2Server extends NETServer { | |||
| 3014 | 3020 | } | |
| 3015 | 3021 | return this; | |
| 3016 | 3022 | } | |
| 3023 | + | ||
| 3024 | + updateSettings(settings) { | ||
| 3025 | + assertIsObject(settings, 'settings'); | ||
| 3026 | + validateSettings(settings); | ||
| 3027 | + this[kOptions].settings = { ...this[kOptions].settings, ...settings }; | ||
| 3028 | + } | ||
| 3017 | 3029 | } | |
| 3018 | 3030 | ||
| 3019 | 3031 | Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,59 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // This test ensures that the Http2SecureServer and Http2Server | ||
| 4 | + // settings are updated when the setting object is valid. | ||
| 5 | + // When the setting object is invalid, this test ensures that | ||
| 6 | + // updateSettings throws an exception. | ||
| 7 | + | ||
| 8 | + const common = require('../common'); | ||
| 9 | + if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
| 10 | + const assert = require('assert'); | ||
| 11 | + const http2 = require('http2'); | ||
| 12 | + | ||
| 13 | + testUpdateSettingsWith({ | ||
| 14 | + server: http2.createSecureServer(), | ||
| 15 | + newServerSettings: { | ||
| 16 | + 'headerTableSize': 1, | ||
| 17 | + 'initialWindowSize': 1, | ||
| 18 | + 'maxConcurrentStreams': 1, | ||
| 19 | + 'maxHeaderListSize': 1, | ||
| 20 | + 'maxFrameSize': 16385, | ||
| 21 | + 'enablePush': false, | ||
| 22 | + 'enableConnectProtocol': true | ||
| 23 | + } | ||
| 24 | + }); | ||
| 25 | + testUpdateSettingsWith({ | ||
| 26 | + server: http2.createServer(), | ||
| 27 | + newServerSettings: { | ||
| 28 | + 'enablePush': false | ||
| 29 | + } | ||
| 30 | + }); | ||
| 31 | + | ||
| 32 | + function testUpdateSettingsWith({ server, newServerSettings }) { | ||
| 33 | + const oldServerSettings = getServerSettings(server); | ||
| 34 | + assert.notDeepStrictEqual(oldServerSettings, newServerSettings); | ||
| 35 | + server.updateSettings(newServerSettings); | ||
| 36 | + const updatedServerSettings = getServerSettings(server); | ||
| 37 | + assert.deepStrictEqual(updatedServerSettings, { ...oldServerSettings, | ||
| 38 | + ...newServerSettings }); | ||
| 39 | + assert.throws(() => server.updateSettings(''), { | ||
| 40 | + message: 'The "settings" argument must be of type object. ' + | ||
| 41 | + 'Received type string (\'\')', | ||
| 42 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 43 | + name: 'TypeError' | ||
| 44 | + }); | ||
| 45 | + assert.throws(() => server.updateSettings({ | ||
| 46 | + 'maxHeaderListSize': 'foo' | ||
| 47 | + }), { | ||
| 48 | + message: 'Invalid value for setting "maxHeaderListSize": foo', | ||
| 49 | + code: 'ERR_HTTP2_INVALID_SETTING_VALUE', | ||
| 50 | + name: 'RangeError' | ||
| 51 | + }); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + function getServerSettings(server) { | ||
| 55 | + const options = Object | ||
| 56 | + .getOwnPropertySymbols(server) | ||
| 57 | + .find((s) => s.toString() === 'Symbol(options)'); | ||
| 58 | + return server[options].settings; | ||
| 59 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments