@openclaw/slack 2026.10.10-beta.4 → 2026.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-configured-zcR9TJJN.mjs → account-configured-35y0-Hso.mjs} +1 -2
- package/dist/.setup/{account-inspect-CmkKiSb9.mjs → account-inspect-Bc7TVU8F.mjs} +3 -4
- package/dist/.setup/{accounts-msihSF3-.mjs → accounts-CEgdyqoW.mjs} +6 -10
- package/dist/.setup/{action-runtime-CgYsBWl6.mjs → action-runtime-DPoxYao5.mjs} +9 -10
- package/dist/.setup/action-runtime.runtime-DWKWaKgC.mjs +1 -0
- package/dist/.setup/{actions-CafoV8hS.mjs → actions-PF2cP6to.mjs} +14 -22
- package/dist/.setup/{approval-handler.runtime-Pty8hAZ9.mjs → approval-handler.runtime-BtRklemy.mjs} +7 -8
- package/dist/.setup/{approval-message-updates-DCnXFLf3.mjs → approval-message-updates-CpwbsEj6.mjs} +2 -3
- package/dist/.setup/{channel-B7jkkIen.mjs → channel-B6bRmYmX.mjs} +32 -39
- package/dist/.setup/{channel-meta-C443t-lI.mjs → channel-meta-C5vsCo3a.mjs} +1 -2
- package/dist/.setup/{channel-type-BrbGGbzI.mjs → channel-type-Dh4vwh1Y.mjs} +5 -6
- package/dist/.setup/{channel.setup-u6QQdbTa.mjs → channel.setup-BBzT6uKA.mjs} +10 -14
- package/dist/.setup/{config-schema-DNnh6bWU.mjs → config-schema-Cz3uId-c.mjs} +2 -4
- package/dist/.setup/{directory-config-Cjj0N8R0.mjs → directory-config-BEPra1E2.mjs} +5 -6
- package/dist/.setup/{directory-live-BIKD-5B_.mjs → directory-live-BkUwPrS0.mjs} +4 -5
- package/dist/.setup/{doctor-contract-Cd4-VzIM.mjs → doctor-contract-HK8aedwU.mjs} +7 -13
- package/dist/.setup/http-GpAVKwSX.mjs +2 -0
- package/dist/.setup/{message-tool-api-BS5ekEA_.mjs → message-tool-api-DeiQJoRV.mjs} +5 -7
- package/dist/.setup/{monitor-B36YZetK.mjs → monitor-DsZUQtTM.mjs} +116 -147
- package/dist/.setup/{outbound-adapter-BlN9vmT-.mjs → outbound-adapter-C0R5jz6S.mjs} +8 -9
- package/dist/.setup/{pipeline.runtime-CT7Krkyw.mjs → pipeline.runtime-CIFVL0kf.mjs} +41 -68
- package/dist/.setup/{plugin-routes-D4qozHVn.mjs → plugin-routes-lXsy_bNV.mjs} +2 -3
- package/dist/.setup/{policy-D4eNyn8m.mjs → policy-Bp1FvE6m.mjs} +4 -6
- package/dist/.setup/{probe-IiHogLQN.mjs → probe-C5VWf3sz.mjs} +11 -19
- package/dist/.setup/{registry-DizWcnNp.mjs → registry-1G0f1zuZ.mjs} +2 -4
- package/dist/.setup/{relay-source-DCfb4yWT.mjs → relay-source-DFBDTA5Z.mjs} +4 -6
- package/dist/.setup/{replies-Dwwt4eVi.mjs → replies-7DRN46EL.mjs} +7 -9
- package/dist/.setup/{reply-blocks-CoZ_dGM_.mjs → reply-blocks-DOjiDr44.mjs} +4 -7
- package/dist/.setup/{resolve-channels-DRRhElwz.mjs → resolve-channels-BNQ1KZXh.mjs} +4 -5
- package/dist/.setup/{resolve-users-Cz8e17ky.mjs → resolve-users-C4dC8Z7D.mjs} +4 -5
- package/dist/.setup/{rolldown-runtime-B4FMCO8f.mjs → rolldown-runtime-nwUcYXjP.mjs} +1 -2
- package/dist/.setup/{runtime-JSVZSWAj.mjs → runtime-C6HKn7Av.mjs} +1 -2
- package/dist/.setup/runtime-setter-api-DrXr965r.mjs +2 -0
- package/dist/.setup/{scopes-DfQVi8Jw.mjs → scopes-C1aeCBa6.mjs} +2 -3
- package/dist/.setup/{secret-contract-B-Qm6aQQ.mjs → secret-contract-D0UY2JWF.mjs} +1 -2
- package/dist/.setup/{secret-contract-api-DB6CMdgc.mjs → secret-contract-api-BhzGpUb0.mjs} +1 -1
- package/dist/.setup/{security-audit-DFGiFLqd.mjs → security-audit-C3hXCfDt.mjs} +2 -3
- package/dist/.setup/{send-pi6r24yv.mjs → send-C5uXkmZV.mjs} +14 -21
- package/dist/.setup/{send-results-eeOu_HYm.mjs → send-results-D-o6PgtS.mjs} +1 -2
- package/dist/.setup/{session-status-DQY4hZLd.mjs → session-status-CHkEn3HM.mjs} +39 -59
- package/dist/.setup/setup-plugin-api-D7DoueEh.mjs +2 -0
- package/dist/.setup/{setup-surface-9WVQgYCT.mjs → setup-surface-CtM1pm-9.mjs} +7 -8
- package/dist/.setup/{shared-DpHCoKy2.mjs → shared-CohTHxM1.mjs} +14 -18
- package/dist/.setup/{slash-dispatch.runtime-BDEJ2s49.mjs → slash-dispatch.runtime-Bnn9a5qB.mjs} +1 -1
- package/dist/.setup/{target-parsing-FFE26kOV.mjs → target-parsing-0pRZtahO.mjs} +1 -2
- package/dist/.setup/{targets-C6LZQL1Q.mjs → targets-BqXz7CpG.mjs} +2 -3
- package/dist/.setup/{thread-ts-Cvt7WD6B.mjs → thread-ts-47Au2-Yn.mjs} +1 -2
- package/dist/.source-module-urls/562d694877afe9d9dcbb3b32a8883c16974738f2aa892c48d45572cdc9a62529.json +1 -1
- package/dist/account-inspect-api.js +2 -3
- package/dist/api.js +17 -17
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-entry.js +1 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/configured-state.js +2 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/http-routes-api.js +1 -1
- package/dist/index.js +2 -3
- package/dist/message-tool-api.js +1 -1
- package/dist/runtime-api.js +12 -12
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/setup-entry.js +4 -5
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/@slack/bolt/node_modules/body-parser/README.md +17 -13
- package/node_modules/@slack/bolt/node_modules/body-parser/lib/read.js +74 -57
- package/node_modules/@slack/bolt/node_modules/body-parser/lib/types/json.js +11 -11
- package/node_modules/@slack/bolt/node_modules/body-parser/lib/types/urlencoded.js +5 -5
- package/node_modules/@slack/bolt/node_modules/body-parser/lib/utils.js +0 -15
- package/node_modules/@slack/bolt/node_modules/body-parser/package.json +7 -12
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +13 -6
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +46 -14
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +65 -28
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +7 -5
- package/node_modules/undici/types/cache-interceptor.d.ts +10 -0
- package/node_modules/undici/types/client.d.ts +10 -4
- package/node_modules/undici/types/errors.d.ts +16 -1
- package/node_modules/undici/types/h2c-client.d.ts +1 -1
- package/node_modules/undici/types/interceptors.d.ts +6 -1
- package/package.json +5 -5
- package/dist/.setup/action-runtime.runtime-WS3mGjut.mjs +0 -1
- package/dist/.setup/http-C9sM-FXe.mjs +0 -2
- package/dist/.setup/runtime-setter-api-Cx_PV-xu.mjs +0 -2
- package/dist/.setup/setup-plugin-api-B18kDKtr.mjs +0 -2
|
@@ -163,9 +163,10 @@ Follows HTTP redirects (3xx responses) automatically.
|
|
|
163
163
|
* `maxRedirections` {number} Maximum number of redirects to follow. Passing
|
|
164
164
|
`0` disables redirect following entirely. **Default:** `undefined`
|
|
165
165
|
(inherits from the per-request `maxRedirections` option).
|
|
166
|
-
* `throwOnMaxRedirect` {boolean} When `true`, throws an error
|
|
167
|
-
redirect
|
|
168
|
-
|
|
166
|
+
* `throwOnMaxRedirect` {boolean} When `true`, throws an error when a
|
|
167
|
+
redirect would be followed but the redirect limit has been reached, instead
|
|
168
|
+
of returning that redirect response. A non-redirect response after exactly
|
|
169
|
+
`maxRedirections` redirects is returned normally. **Default:** `false`.
|
|
169
170
|
* `stripHeadersOnRedirect` {string[]} List of header names to remove from
|
|
170
171
|
the request when following any redirect. **Default:** `[]`.
|
|
171
172
|
* `stripHeadersOnCrossOriginRedirect` {string[]} List of header names to
|
|
@@ -198,7 +199,10 @@ const agent = new Agent().compose(
|
|
|
198
199
|
## `interceptors.decompress([opts])`
|
|
199
200
|
|
|
200
201
|
Automatically decompresses response bodies encoded with `gzip`, `x-gzip`,
|
|
201
|
-
`br` (Brotli), `deflate`,
|
|
202
|
+
`br` (Brotli), `deflate`, or `zstd`. Any other coding, including `compress`
|
|
203
|
+
and `x-compress`, is left untouched, matching `fetch()`. As required by
|
|
204
|
+
[RFC 9659](https://www.rfc-editor.org/rfc/rfc9659.html), a `zstd` frame that
|
|
205
|
+
requires a window size larger than 8 MB fails to decode.
|
|
202
206
|
|
|
203
207
|
> **Experimental:** This interceptor is experimental and subject to change.
|
|
204
208
|
> A one-time `ExperimentalWarning` is emitted on first use.
|
|
@@ -244,8 +248,11 @@ The error body is automatically decoded for `application/json` and
|
|
|
244
248
|
|
|
245
249
|
**Parameters**
|
|
246
250
|
|
|
247
|
-
* `opts` {Object} (optional)
|
|
248
|
-
|
|
251
|
+
* `opts` {Object} (optional)
|
|
252
|
+
* `maxSize` {number} Maximum number of response body bytes to include in the
|
|
253
|
+
error. If the body exceeds this limit, the resulting `ResponseError`
|
|
254
|
+
contains the retained prefix with `bodyTruncated` set to `true`. Set to `0`
|
|
255
|
+
to disable the limit. **Default:** `1048576` (1 MiB).
|
|
249
256
|
|
|
250
257
|
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
|
|
251
258
|
|
|
@@ -57,9 +57,10 @@ added: v4.0.0
|
|
|
57
57
|
* `opts` {DispatchOptions} The dispatch options for the request. In addition to
|
|
58
58
|
the standard dispatch options, the following redirect-specific fields are
|
|
59
59
|
recognized:
|
|
60
|
-
* `throwOnMaxRedirect` {boolean} When `true`, an error is thrown
|
|
61
|
-
`maxRedirections`
|
|
62
|
-
|
|
60
|
+
* `throwOnMaxRedirect` {boolean} When `true`, an error is thrown when a
|
|
61
|
+
redirect would be followed but `maxRedirections` has been reached, instead of
|
|
62
|
+
returning that redirect response. A non-redirect response after exactly
|
|
63
|
+
`maxRedirections` redirects is returned normally. **Default:** `false`.
|
|
63
64
|
* `stripHeadersOnRedirect` {string[]} Header names to remove from the request on
|
|
64
65
|
every redirect hop. **Default:** `null`.
|
|
65
66
|
* `stripHeadersOnCrossOriginRedirect` {string[]} Additional header names to
|
|
@@ -165,13 +166,15 @@ added: v7.0.0
|
|
|
165
166
|
* `statusMessage` {string} The HTTP status message.
|
|
166
167
|
|
|
167
168
|
Inspects the response headers to decide whether to follow a redirect. When the
|
|
168
|
-
status code is redirectable, the
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
status code is redirectable, the response has a `Location` header, the
|
|
170
|
+
`maxRedirections` limit has not been reached, and the request body has not been
|
|
171
|
+
consumed, the `location` property is set, the method and headers are adjusted
|
|
172
|
+
for the next hop, and the response is not forwarded. Otherwise the event is
|
|
173
|
+
forwarded to the wrapped `handler`.
|
|
174
|
+
|
|
175
|
+
Throws when `throwOnMaxRedirect` is `true` and a redirect that would otherwise be
|
|
176
|
+
followed arrives after `maxRedirections` redirects have already been followed,
|
|
177
|
+
and throws an [`InvalidArgumentError`][] if a
|
|
175
178
|
redirect loop is detected (for example when a [`Client`][] or [`Pool`][] is used
|
|
176
179
|
for a cross-origin redirect; use an [`Agent`][] instead).
|
|
177
180
|
|
|
@@ -13,7 +13,7 @@ It is also a Stranger Things reference.
|
|
|
13
13
|
|
|
14
14
|
Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
|
|
15
15
|
|
|
16
|
-
Looking to contribute? Start by reading the [contributing guide](
|
|
16
|
+
Looking to contribute? Start by reading the [contributing guide](https://github.com/nodejs/undici/blob/main/CONTRIBUTING.md)
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -417,7 +417,7 @@ For more information about their behavior, please reference the body mixin from
|
|
|
417
417
|
|
|
418
418
|
## Common API Methods
|
|
419
419
|
|
|
420
|
-
This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [
|
|
420
|
+
This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [`api`](./api/) folder and are accessible via the navigation list on the left side of the docs site.
|
|
421
421
|
|
|
422
422
|
For the top-level APIs below, the `url` argument supplies the request origin and
|
|
423
423
|
path. Do not pass `origin` or `path` in the second `options` argument. The linked
|
|
@@ -427,19 +427,19 @@ lower-level APIs that do not receive a separate `url` argument.
|
|
|
427
427
|
### `undici.request([url, options])`
|
|
428
428
|
|
|
429
429
|
* `url` {string|URL|UrlObject}
|
|
430
|
-
* `options` {RequestOptions} See [`RequestOptions`](./
|
|
430
|
+
* `options` {RequestOptions} See [`RequestOptions`](./api/Dispatcher.md#parameter-requestoptions).
|
|
431
431
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
432
432
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
433
433
|
* Returns: {Promise} A promise with the result of the `Dispatcher.request` method.
|
|
434
434
|
|
|
435
435
|
Calls `options.dispatcher.request(options)`.
|
|
436
436
|
|
|
437
|
-
See [Dispatcher.request](./
|
|
437
|
+
See [Dispatcher.request](./api/Dispatcher.md#dispatcherrequestoptions-callback) for more details, and [request examples](https://github.com/nodejs/undici/blob/main/docs/examples/README.md) for examples.
|
|
438
438
|
|
|
439
439
|
### `undici.stream([url, options, ]factory)`
|
|
440
440
|
|
|
441
441
|
* `url` {string|URL|UrlObject}
|
|
442
|
-
* `options` {StreamOptions} See [`StreamOptions`](./
|
|
442
|
+
* `options` {StreamOptions} See [`StreamOptions`](./api/Dispatcher.md#parameter-streamoptions).
|
|
443
443
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
444
444
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
445
445
|
* `factory` {Function} `Dispatcher.stream.factory`.
|
|
@@ -447,12 +447,12 @@ See [Dispatcher.request](./docs/docs/api/Dispatcher.md#dispatcherrequestoptions-
|
|
|
447
447
|
|
|
448
448
|
Calls `options.dispatcher.stream(options, factory)`.
|
|
449
449
|
|
|
450
|
-
See [Dispatcher.stream](./
|
|
450
|
+
See [Dispatcher.stream](./api/Dispatcher.md#dispatcherstreamoptions-factory-callback) for more details.
|
|
451
451
|
|
|
452
452
|
### `undici.pipeline([url, options, ]handler)`
|
|
453
453
|
|
|
454
454
|
* `url` {string|URL|UrlObject}
|
|
455
|
-
* `options` {PipelineOptions} See [`PipelineOptions`](./
|
|
455
|
+
* `options` {PipelineOptions} See [`PipelineOptions`](./api/Dispatcher.md#parameter-pipelineoptions).
|
|
456
456
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
457
457
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
458
458
|
* `handler` {Function} `Dispatcher.pipeline.handler`.
|
|
@@ -460,21 +460,21 @@ See [Dispatcher.stream](./docs/docs/api/Dispatcher.md#dispatcherstreamoptions-fa
|
|
|
460
460
|
|
|
461
461
|
Calls `options.dispatch.pipeline(options, handler)`.
|
|
462
462
|
|
|
463
|
-
See [Dispatcher.pipeline](./
|
|
463
|
+
See [Dispatcher.pipeline](./api/Dispatcher.md#dispatcherpipelineoptions-handler) for more details.
|
|
464
464
|
|
|
465
465
|
### `undici.connect([url, options])`
|
|
466
466
|
|
|
467
467
|
Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
|
|
468
468
|
|
|
469
469
|
* `url` {string|URL|UrlObject}
|
|
470
|
-
* `options` {ConnectOptions} See [`ConnectOptions`](./
|
|
470
|
+
* `options` {ConnectOptions} See [`ConnectOptions`](./api/Dispatcher.md#parameter-connectoptions).
|
|
471
471
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
472
472
|
* `callback` {Function} (optional) — `(err, data) => void`.
|
|
473
473
|
* Returns: {Promise} A promise with the result of the `Dispatcher.connect` method.
|
|
474
474
|
|
|
475
475
|
Calls `options.dispatch.connect(options)`.
|
|
476
476
|
|
|
477
|
-
See [Dispatcher.connect](./
|
|
477
|
+
See [Dispatcher.connect](./api/Dispatcher.md#dispatcherconnectoptions-callback) for more details.
|
|
478
478
|
|
|
479
479
|
### `undici.fetch(input[, init])`
|
|
480
480
|
|
|
@@ -647,14 +647,14 @@ Undici limits the number of `Content-Encoding` layers in a response to **5** to
|
|
|
647
647
|
Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
|
|
648
648
|
|
|
649
649
|
* `url` {string|URL|UrlObject}
|
|
650
|
-
* `options` {UpgradeOptions} See [`UpgradeOptions`](./
|
|
650
|
+
* `options` {UpgradeOptions} See [`UpgradeOptions`](./api/Dispatcher.md#parameter-upgradeoptions).
|
|
651
651
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
652
652
|
* `callback` {Function} (optional) — `(error, data) => void`.
|
|
653
653
|
* Returns: {Promise} A promise with the result of the `Dispatcher.upgrade` method.
|
|
654
654
|
|
|
655
655
|
Calls `options.dispatcher.upgrade(options)`.
|
|
656
656
|
|
|
657
|
-
See [Dispatcher.upgrade](./
|
|
657
|
+
See [Dispatcher.upgrade](./api/Dispatcher.md#dispatcherupgradeoptions-callback) for more details.
|
|
658
658
|
|
|
659
659
|
### `undici.setGlobalDispatcher(dispatcher)`
|
|
660
660
|
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
{
|
|
2
|
-
"AbortError": "/api/Errors.
|
|
3
|
-
"Agent": "/api/Agent.
|
|
4
|
-
"AgentDispatchOptions": "/api/Agent.
|
|
5
|
-
"AgentOptions": "/api/Agent.
|
|
6
|
-
"BalancedPool": "/api/BalancedPool.
|
|
7
|
-
"BalancedPoolOptions": "/api/BalancedPool.
|
|
8
|
-
"BodyMixin": "/api/Fetch.
|
|
2
|
+
"AbortError": "/api/Errors.html#class-aborterror",
|
|
3
|
+
"Agent": "/api/Agent.html#class-agent",
|
|
4
|
+
"AgentDispatchOptions": "/api/Agent.html#agentdispatchoptions-handler",
|
|
5
|
+
"AgentOptions": "/api/Agent.html#new-agentoptions",
|
|
6
|
+
"BalancedPool": "/api/BalancedPool.html#class-balancedpool",
|
|
7
|
+
"BalancedPoolOptions": "/api/BalancedPool.html#parameter-balancedpooloptions",
|
|
8
|
+
"BodyMixin": "/api/Fetch.html#new-formdata",
|
|
9
9
|
"Buffer": "https://nodejs.org/api/buffer.html#class-buffer",
|
|
10
|
-
"BuildOptions": "/api/Connector.
|
|
11
|
-
"CacheKey": "/api/CacheStore.
|
|
12
|
-
"CacheStore": "/api/CacheStore.
|
|
13
|
-
"CacheValue": "/api/CacheStore.
|
|
14
|
-
"ClientDestroyedError": "/api/Errors.
|
|
15
|
-
"ClientOptions": "/api/Client.
|
|
16
|
-
"ClientStats": "/api/ClientStats.
|
|
17
|
-
"ConnectOptions": "/api/Dispatcher.
|
|
18
|
-
"Cookie": "/api/Cookies.
|
|
19
|
-
"DispatchController": "/api/Dispatcher.
|
|
20
|
-
"DispatchHandler": "/api/Dispatcher.
|
|
21
|
-
"DispatchOptions": "/api/Dispatcher.
|
|
22
|
-
"Dispatcher": "/api/Dispatcher.
|
|
10
|
+
"BuildOptions": "/api/Connector.html#buildconnectoroptions",
|
|
11
|
+
"CacheKey": "/api/CacheStore.html#cachekey",
|
|
12
|
+
"CacheStore": "/api/CacheStore.html#new-memorycachestoreoptions",
|
|
13
|
+
"CacheValue": "/api/CacheStore.html#cachevalue",
|
|
14
|
+
"ClientDestroyedError": "/api/Errors.html#class-clientdestroyederror",
|
|
15
|
+
"ClientOptions": "/api/Client.html#new-clienturl-options",
|
|
16
|
+
"ClientStats": "/api/ClientStats.html#class-clientstats",
|
|
17
|
+
"ConnectOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
18
|
+
"Cookie": "/api/Cookies.html#cookie",
|
|
19
|
+
"DispatchController": "/api/Dispatcher.html#class-dispatcher",
|
|
20
|
+
"DispatchHandler": "/api/Dispatcher.html#class-dispatcher",
|
|
21
|
+
"DispatchOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
22
|
+
"Dispatcher": "/api/Dispatcher.html#class-dispatcher",
|
|
23
23
|
"Duplex": "https://nodejs.org/api/stream.html#class-streamduplex",
|
|
24
|
-
"EnvHttpProxyAgent": "/api/EnvHttpProxyAgent.
|
|
25
|
-
"EnvHttpProxyAgentOptions": "/api/EnvHttpProxyAgent.
|
|
24
|
+
"EnvHttpProxyAgent": "/api/EnvHttpProxyAgent.html#class-envhttpproxyagent",
|
|
25
|
+
"EnvHttpProxyAgentOptions": "/api/EnvHttpProxyAgent.html#new-envhttpproxyagentoptions",
|
|
26
26
|
"EventEmitter": "https://nodejs.org/api/events.html#class-eventemitter",
|
|
27
|
-
"GetResult": "/api/CacheStore.
|
|
28
|
-
"H2CClientOptions": "/api/H2CClient.
|
|
27
|
+
"GetResult": "/api/CacheStore.html#getresult",
|
|
28
|
+
"H2CClientOptions": "/api/H2CClient.html#new-h2cclienturl-options",
|
|
29
29
|
"HeadersInit": "https://developer.mozilla.org/docs/Web/API/Headers/Headers",
|
|
30
|
-
"InvalidArgumentError": "/api/Errors.
|
|
30
|
+
"InvalidArgumentError": "/api/Errors.html#class-invalidargumenterror",
|
|
31
31
|
"Iterable": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols",
|
|
32
|
-
"MaxOriginsReachedError": "/api/Errors.
|
|
33
|
-
"MockAgent": "/api/MockAgent.
|
|
34
|
-
"MockAgentOptions": "/api/MockAgent.
|
|
35
|
-
"MockCallHistory": "/api/MockCallHistory.
|
|
36
|
-
"MockCallHistoryLog": "/api/MockCallHistoryLog.
|
|
37
|
-
"MockClient": "/api/MockClient.
|
|
38
|
-
"MockClientOptions": "/api/MockClient.
|
|
39
|
-
"MockInterceptor": "/api/MockPool.
|
|
40
|
-
"MockInterceptor.Options": "/api/MockPool.
|
|
41
|
-
"MockPool": "/api/MockPool.
|
|
42
|
-
"MockPoolInterceptOptions": "/api/MockPool.
|
|
43
|
-
"MockPoolOptions": "/api/MockPool.
|
|
44
|
-
"MockResponseOptions": "/api/MockPool.
|
|
45
|
-
"MockScope": "/api/MockPool.
|
|
46
|
-
"PendingInterceptor": "/api/MockAgent.
|
|
47
|
-
"PipelineOptions": "/api/Dispatcher.
|
|
48
|
-
"Pool": "/api/Pool.
|
|
49
|
-
"PoolOptions": "/api/Pool.
|
|
50
|
-
"PoolStats": "/api/PoolStats.
|
|
51
|
-
"ProxyAgent": "/api/ProxyAgent.
|
|
52
|
-
"ProxyAgentOptions": "/api/ProxyAgent.
|
|
32
|
+
"MaxOriginsReachedError": "/api/Errors.html#class-maxoriginsreachederror",
|
|
33
|
+
"MockAgent": "/api/MockAgent.html#class-mockagent",
|
|
34
|
+
"MockAgentOptions": "/api/MockAgent.html#parameter-mockagentoptions",
|
|
35
|
+
"MockCallHistory": "/api/MockCallHistory.html#class-mockcallhistory",
|
|
36
|
+
"MockCallHistoryLog": "/api/MockCallHistoryLog.html#class-mockcallhistorylog",
|
|
37
|
+
"MockClient": "/api/MockClient.html#class-mockclient",
|
|
38
|
+
"MockClientOptions": "/api/MockClient.html#parameter-mockclientoptions",
|
|
39
|
+
"MockInterceptor": "/api/MockPool.html#return-mockinterceptor",
|
|
40
|
+
"MockInterceptor.Options": "/api/MockPool.html#parameter-mockpoolinterceptoptions",
|
|
41
|
+
"MockPool": "/api/MockPool.html#class-mockpool",
|
|
42
|
+
"MockPoolInterceptOptions": "/api/MockPool.html#parameter-mockpoolinterceptoptions",
|
|
43
|
+
"MockPoolOptions": "/api/MockPool.html#parameter-mockpooloptions",
|
|
44
|
+
"MockResponseOptions": "/api/MockPool.html#parameter-mockresponseoptions",
|
|
45
|
+
"MockScope": "/api/MockPool.html#return-mockscope",
|
|
46
|
+
"PendingInterceptor": "/api/MockAgent.html#new-mockagentoptions",
|
|
47
|
+
"PipelineOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
48
|
+
"Pool": "/api/Pool.html#class-pool",
|
|
49
|
+
"PoolOptions": "/api/Pool.html#new-poolurl-options",
|
|
50
|
+
"PoolStats": "/api/PoolStats.html#class-poolstats",
|
|
51
|
+
"ProxyAgent": "/api/ProxyAgent.html#class-proxyagent",
|
|
52
|
+
"ProxyAgentOptions": "/api/ProxyAgent.html#new-proxyagentoptions",
|
|
53
53
|
"Readable": "https://nodejs.org/api/stream.html#class-streamreadable",
|
|
54
54
|
"Record": "https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type",
|
|
55
|
-
"RequestInit": "/api/Fetch.
|
|
56
|
-
"RequestOptions": "/api/Dispatcher.
|
|
57
|
-
"ResponseInit": "/api/Fetch.
|
|
58
|
-
"RetryContext": "/api/RetryHandler.
|
|
59
|
-
"RetryHandler": "/api/RetryHandler.
|
|
60
|
-
"RetryHandlers": "/api/RetryHandler.
|
|
61
|
-
"RetryOptions": "/api/RetryHandler.
|
|
62
|
-
"RetryState": "/api/RetryHandler.
|
|
63
|
-
"RoundRobinPoolOptions": "/api/RoundRobinPool.
|
|
64
|
-
"SnapshotRecorder": "/api/SnapshotAgent.
|
|
55
|
+
"RequestInit": "/api/Fetch.html#new-formdata",
|
|
56
|
+
"RequestOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
57
|
+
"ResponseInit": "/api/Fetch.html#new-formdata",
|
|
58
|
+
"RetryContext": "/api/RetryHandler.html#retrycontext",
|
|
59
|
+
"RetryHandler": "/api/RetryHandler.html#class-retryhandler",
|
|
60
|
+
"RetryHandlers": "/api/RetryHandler.html#parameter-retryhandlers",
|
|
61
|
+
"RetryOptions": "/api/RetryHandler.html#retryoptions",
|
|
62
|
+
"RetryState": "/api/RetryHandler.html#retrystate",
|
|
63
|
+
"RoundRobinPoolOptions": "/api/RoundRobinPool.html#parameter-roundrobinpooloptions",
|
|
64
|
+
"SnapshotRecorder": "/api/SnapshotAgent.html#new-snapshotagentoptions",
|
|
65
65
|
"Socket": "https://nodejs.org/api/net.html#class-netsocket",
|
|
66
|
-
"SocketInfo": "/api/Errors.
|
|
67
|
-
"StreamOptions": "/api/Dispatcher.
|
|
66
|
+
"SocketInfo": "/api/Errors.html#new-requestretryerrormessage-code-options",
|
|
67
|
+
"StreamOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
68
68
|
"TLSSocket": "https://nodejs.org/api/tls.html#class-tlstlssocket",
|
|
69
|
-
"UndiciError": "/api/Errors.
|
|
70
|
-
"UndiciHeaders": "/api/Dispatcher.
|
|
71
|
-
"UpgradeOptions": "/api/Dispatcher.
|
|
72
|
-
"UrlObject": "/index.
|
|
73
|
-
"WebSocketInit": "/api/WebSocket.
|
|
74
|
-
"WebSocketStreamOptions": "/api/WebSocket.
|
|
69
|
+
"UndiciError": "/api/Errors.html#class-undicierror",
|
|
70
|
+
"UndiciHeaders": "/api/Dispatcher.html#class-dispatcher",
|
|
71
|
+
"UpgradeOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
72
|
+
"UrlObject": "/index.html#urlobject",
|
|
73
|
+
"WebSocketInit": "/api/WebSocket.html#new-websocketurl-protocols",
|
|
74
|
+
"WebSocketStreamOptions": "/api/WebSocket.html#new-websocketurl-protocols",
|
|
75
75
|
"Writable": "https://nodejs.org/api/stream.html#class-streamwritable",
|
|
76
|
-
"buildConnector.BuildOptions": "/api/Connector.
|
|
76
|
+
"buildConnector.BuildOptions": "/api/Connector.html#buildconnectoroptions",
|
|
77
77
|
"net.Socket": "https://nodejs.org/api/net.html#class-netsocket",
|
|
78
78
|
"stream.Readable": "https://nodejs.org/api/stream.html#class-streamreadable"
|
|
79
|
-
}
|
|
79
|
+
}
|
|
@@ -100,6 +100,11 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
100
100
|
|
|
101
101
|
const entry = entries ? findEntry(key, entries, now) : null
|
|
102
102
|
|
|
103
|
+
if (entry != null) {
|
|
104
|
+
this.#entries.delete(topLevelKey)
|
|
105
|
+
this.#entries.set(topLevelKey, entries)
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
return entry == null
|
|
104
109
|
? undefined
|
|
105
110
|
: {
|
|
@@ -148,11 +153,13 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
148
153
|
},
|
|
149
154
|
final (callback) {
|
|
150
155
|
let entries = store.#entries.get(topLevelKey)
|
|
151
|
-
if (
|
|
156
|
+
if (entries) {
|
|
157
|
+
store.#entries.delete(topLevelKey)
|
|
158
|
+
} else {
|
|
152
159
|
entries = []
|
|
153
|
-
store.#entries.set(topLevelKey, entries)
|
|
154
160
|
}
|
|
155
|
-
|
|
161
|
+
store.#entries.set(topLevelKey, entries)
|
|
162
|
+
const previousEntry = findEntry(key, entries, -Infinity)
|
|
156
163
|
if (previousEntry) {
|
|
157
164
|
const index = entries.indexOf(previousEntry)
|
|
158
165
|
entries.splice(index, 1, entry)
|
|
@@ -177,16 +184,7 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
177
184
|
store.#hasEmittedMaxSizeEvent = true
|
|
178
185
|
}
|
|
179
186
|
|
|
180
|
-
|
|
181
|
-
for (const [key, entries] of store.#entries) {
|
|
182
|
-
for (const entry of entries.splice(0, Math.ceil(entries.length / 2))) {
|
|
183
|
-
store.#size -= entry.size
|
|
184
|
-
store.#count -= 1
|
|
185
|
-
}
|
|
186
|
-
if (entries.length === 0) {
|
|
187
|
-
store.#entries.delete(key)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
187
|
+
store.#evict(entry)
|
|
190
188
|
|
|
191
189
|
// Reset the event flag after eviction
|
|
192
190
|
if (store.#size < store.#maxSize && store.#count < store.#maxCount) {
|
|
@@ -199,6 +197,43 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
199
197
|
})
|
|
200
198
|
}
|
|
201
199
|
|
|
200
|
+
#evict (keep) {
|
|
201
|
+
const targetSize = this.#maxSize / 2
|
|
202
|
+
const targetCount = this.#maxCount / 2
|
|
203
|
+
|
|
204
|
+
for (const [key, entries] of this.#entries) {
|
|
205
|
+
for (let i = 0; i < entries.length && (this.#size > targetSize || this.#count > targetCount);) {
|
|
206
|
+
const entry = entries[i]
|
|
207
|
+
if (entry === keep) {
|
|
208
|
+
i++
|
|
209
|
+
continue
|
|
210
|
+
}
|
|
211
|
+
entries.splice(i, 1)
|
|
212
|
+
this.#size -= entry.size
|
|
213
|
+
this.#count -= 1
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (entries.length === 0) {
|
|
217
|
+
this.#entries.delete(key)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (this.#size <= targetSize && this.#count <= targetCount) {
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.#size > this.#maxSize || this.#count > this.#maxCount) {
|
|
226
|
+
const topLevelKey = `${keep.origin}:${keep.path}`
|
|
227
|
+
const entries = this.#entries.get(topLevelKey)
|
|
228
|
+
entries.splice(entries.indexOf(keep), 1)
|
|
229
|
+
this.#size -= keep.size
|
|
230
|
+
this.#count -= 1
|
|
231
|
+
if (entries.length === 0) {
|
|
232
|
+
this.#entries.delete(topLevelKey)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
202
237
|
/**
|
|
203
238
|
* @param {CacheKey} key
|
|
204
239
|
*/
|
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
const { Writable } = require('node:stream')
|
|
4
4
|
const { assertCacheKey, assertCacheValue } = require('../util/cache.js')
|
|
5
|
+
const { zstdCompressSync, zstdDecompressSync } = require('node:zlib')
|
|
5
6
|
|
|
6
7
|
let DatabaseSync
|
|
7
8
|
|
|
8
|
-
const VERSION =
|
|
9
|
+
const VERSION = 4
|
|
9
10
|
|
|
10
11
|
// 2gb
|
|
11
12
|
const MAX_ENTRY_SIZE = 2 * 1000 * 1000 * 1000
|
|
12
13
|
|
|
14
|
+
// 1MiB
|
|
15
|
+
const COMPRESS_THRESHOLD = 1024 * 1024
|
|
16
|
+
|
|
17
|
+
// zstd support landed in Node 22.19.0/23.4.0, so it may be missing even when
|
|
18
|
+
// node:sqlite is available.
|
|
19
|
+
const hasZstd = typeof zstdCompressSync === 'function' && typeof zstdDecompressSync === 'function'
|
|
20
|
+
|
|
13
21
|
/**
|
|
14
22
|
* @typedef {import('../../types/cache-interceptor.d.ts').default.CacheStore} CacheStore
|
|
15
23
|
* @implements {CacheStore}
|
|
@@ -17,6 +25,7 @@ const MAX_ENTRY_SIZE = 2 * 1000 * 1000 * 1000
|
|
|
17
25
|
* @typedef {{
|
|
18
26
|
* id: Readonly<number>,
|
|
19
27
|
* body?: Uint8Array
|
|
28
|
+
* compressed?: string
|
|
20
29
|
* statusCode: number
|
|
21
30
|
* statusMessage: string
|
|
22
31
|
* headers?: string
|
|
@@ -31,6 +40,7 @@ const MAX_ENTRY_SIZE = 2 * 1000 * 1000 * 1000
|
|
|
31
40
|
module.exports = class SqliteCacheStore {
|
|
32
41
|
#maxEntrySize = MAX_ENTRY_SIZE
|
|
33
42
|
#maxCount = Infinity
|
|
43
|
+
#compressThreshold = COMPRESS_THRESHOLD
|
|
34
44
|
|
|
35
45
|
/**
|
|
36
46
|
* @type {import('node:sqlite').DatabaseSync}
|
|
@@ -107,6 +117,17 @@ module.exports = class SqliteCacheStore {
|
|
|
107
117
|
}
|
|
108
118
|
this.#maxCount = opts.maxCount
|
|
109
119
|
}
|
|
120
|
+
|
|
121
|
+
if (opts.compressThreshold !== undefined) {
|
|
122
|
+
if (
|
|
123
|
+
typeof opts.compressThreshold !== 'number' ||
|
|
124
|
+
!Number.isInteger(opts.compressThreshold) ||
|
|
125
|
+
opts.compressThreshold < 0
|
|
126
|
+
) {
|
|
127
|
+
throw new TypeError('SqliteCacheStore options.compressThreshold must be a non-negative integer')
|
|
128
|
+
}
|
|
129
|
+
this.#compressThreshold = opts.compressThreshold
|
|
130
|
+
}
|
|
110
131
|
}
|
|
111
132
|
|
|
112
133
|
if (!DatabaseSync) {
|
|
@@ -128,6 +149,7 @@ module.exports = class SqliteCacheStore {
|
|
|
128
149
|
|
|
129
150
|
-- Data returned to the interceptor
|
|
130
151
|
body BUF NULL,
|
|
152
|
+
compressed TEXT NULL,
|
|
131
153
|
deleteAt INTEGER NOT NULL,
|
|
132
154
|
statusCode INTEGER NOT NULL,
|
|
133
155
|
statusMessage TEXT NOT NULL,
|
|
@@ -147,6 +169,7 @@ module.exports = class SqliteCacheStore {
|
|
|
147
169
|
SELECT
|
|
148
170
|
id,
|
|
149
171
|
body,
|
|
172
|
+
compressed,
|
|
150
173
|
deleteAt,
|
|
151
174
|
statusCode,
|
|
152
175
|
statusMessage,
|
|
@@ -167,6 +190,7 @@ module.exports = class SqliteCacheStore {
|
|
|
167
190
|
this.#updateValueQuery = this.#db.prepare(`
|
|
168
191
|
UPDATE cacheInterceptorV${VERSION} SET
|
|
169
192
|
body = ?,
|
|
193
|
+
compressed = ?,
|
|
170
194
|
deleteAt = ?,
|
|
171
195
|
statusCode = ?,
|
|
172
196
|
statusMessage = ?,
|
|
@@ -185,6 +209,7 @@ module.exports = class SqliteCacheStore {
|
|
|
185
209
|
url,
|
|
186
210
|
method,
|
|
187
211
|
body,
|
|
212
|
+
compressed,
|
|
188
213
|
deleteAt,
|
|
189
214
|
statusCode,
|
|
190
215
|
statusMessage,
|
|
@@ -194,7 +219,7 @@ module.exports = class SqliteCacheStore {
|
|
|
194
219
|
vary,
|
|
195
220
|
cachedAt,
|
|
196
221
|
staleAt
|
|
197
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
222
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
198
223
|
`)
|
|
199
224
|
|
|
200
225
|
this.#deleteByUrlQuery = this.#db.prepare(
|
|
@@ -237,7 +262,11 @@ module.exports = class SqliteCacheStore {
|
|
|
237
262
|
const value = this.#findValue(key)
|
|
238
263
|
return value
|
|
239
264
|
? {
|
|
240
|
-
body: value.body
|
|
265
|
+
body: value.body
|
|
266
|
+
? value.compressed === 'zstd'
|
|
267
|
+
? zstdDecompressSync(Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength))
|
|
268
|
+
: Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength)
|
|
269
|
+
: undefined,
|
|
241
270
|
statusCode: value.statusCode,
|
|
242
271
|
statusMessage: value.statusMessage,
|
|
243
272
|
headers: value.headers ? JSON.parse(value.headers) : undefined,
|
|
@@ -268,11 +297,22 @@ module.exports = class SqliteCacheStore {
|
|
|
268
297
|
return
|
|
269
298
|
}
|
|
270
299
|
|
|
300
|
+
let compressed = null
|
|
301
|
+
let storedBody = body
|
|
302
|
+
if (body && hasZstd && (size > this.#compressThreshold || isCompressibleContentType(getContentType(value.headers)))) {
|
|
303
|
+
const candidate = zstdCompressSync(body)
|
|
304
|
+
if (candidate.byteLength < body.byteLength) {
|
|
305
|
+
storedBody = candidate
|
|
306
|
+
compressed = 'zstd'
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
271
310
|
const existingValue = this.#findValue(key, true)
|
|
272
311
|
if (existingValue) {
|
|
273
312
|
// Updating an existing response, let's overwrite it
|
|
274
313
|
this.#updateValueQuery.run(
|
|
275
|
-
|
|
314
|
+
storedBody,
|
|
315
|
+
compressed,
|
|
276
316
|
value.deleteAt,
|
|
277
317
|
value.statusCode,
|
|
278
318
|
value.statusMessage,
|
|
@@ -289,7 +329,8 @@ module.exports = class SqliteCacheStore {
|
|
|
289
329
|
this.#insertValueQuery.run(
|
|
290
330
|
url,
|
|
291
331
|
key.method,
|
|
292
|
-
|
|
332
|
+
storedBody,
|
|
333
|
+
compressed,
|
|
293
334
|
value.deleteAt,
|
|
294
335
|
value.statusCode,
|
|
295
336
|
value.statusMessage,
|
|
@@ -467,3 +508,40 @@ function headerValueEquals (lhs, rhs) {
|
|
|
467
508
|
|
|
468
509
|
return lhs === rhs
|
|
469
510
|
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @param {Record<string, string|string[]>|null|undefined} headers
|
|
514
|
+
* @returns {string|undefined}
|
|
515
|
+
*/
|
|
516
|
+
function getContentType (headers) {
|
|
517
|
+
if (headers == null) {
|
|
518
|
+
return undefined
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
for (const key in headers) {
|
|
522
|
+
if (key.toLowerCase() === 'content-type') {
|
|
523
|
+
const value = headers[key]
|
|
524
|
+
return Array.isArray(value) ? value[0] : value
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return undefined
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* @param {string|undefined} contentType
|
|
533
|
+
* @returns {boolean}
|
|
534
|
+
*/
|
|
535
|
+
function isCompressibleContentType (contentType) {
|
|
536
|
+
if (contentType == null) {
|
|
537
|
+
return false
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const type = contentType.toLowerCase()
|
|
541
|
+
|
|
542
|
+
// text/* and application/json, xml, javascript, ... are easily compressible
|
|
543
|
+
// even at smaller sizes, so ignore the compressThreshold for them.
|
|
544
|
+
return /^text\//.test(type) ||
|
|
545
|
+
/^application\/(json|xml|javascript|x-www-form-urlencoded|graphql)(\s|;|$)/.test(type) ||
|
|
546
|
+
/\+(json|xml)(\s|;|$)/.test(type)
|
|
547
|
+
}
|
|
@@ -41,16 +41,22 @@ const SessionCache = class WeakSessionCache {
|
|
|
41
41
|
if (this._sessionCache.has(sessionKey)) {
|
|
42
42
|
this._sessionCache.delete(sessionKey)
|
|
43
43
|
} else if (this._sessionCache.size >= this._maxCachedSessions) {
|
|
44
|
+
// Make room for the new session: prefer an entry whose session has
|
|
45
|
+
// already been collected, otherwise evict the oldest one.
|
|
46
|
+
let evicted = false
|
|
44
47
|
for (const [key, ref] of this._sessionCache) {
|
|
45
48
|
if (ref.deref() === undefined) {
|
|
46
49
|
this._sessionCache.delete(key)
|
|
47
|
-
|
|
50
|
+
evicted = true
|
|
51
|
+
break
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
if (!evicted) {
|
|
56
|
+
const oldest = this._sessionCache.keys().next()
|
|
57
|
+
if (!oldest.done) {
|
|
58
|
+
this._sessionCache.delete(oldest.value)
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -114,7 +114,18 @@ for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
|
114
114
|
lowerCasedKey
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Default WebSocket receive limits (see `webSocket` in Client.md). Used by
|
|
119
|
+
* DispatcherBase#webSocketOptions and by the WebSocket parser when the
|
|
120
|
+
* dispatcher doesn't provide a value, so a dispatcher without
|
|
121
|
+
* `webSocketOptions` (a custom one, or a wrapper) doesn't remove the limits.
|
|
122
|
+
*/
|
|
123
|
+
const defaultWebSocketMaxFragments = 131072
|
|
124
|
+
const defaultWebSocketMaxPayloadSize = 128 * 1024 * 1024 // 128 MB
|
|
125
|
+
|
|
117
126
|
module.exports = {
|
|
118
127
|
wellknownHeaderNames,
|
|
119
|
-
headerNameLowerCasedRecord
|
|
128
|
+
headerNameLowerCasedRecord,
|
|
129
|
+
defaultWebSocketMaxFragments,
|
|
130
|
+
defaultWebSocketMaxPayloadSize
|
|
120
131
|
}
|