@yanglaofish/fishtools 0.5.1 → 0.5.3
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/README.md +25 -11
- package/manual/README.md +25 -11
- package/manual/docs/deployment.md +3 -3
- package/manual/docs/examples/action-plugin/package.json +1 -1
- package/manual/docs/modules.md +2 -0
- package/manual/docs/plugin-development.md +18 -5
- package/manual/docs/releases.md +56 -6
- package/manual/docs/superpowers/plans/2026-10-13-command-shortcuts.md +108 -0
- package/manual/docs/superpowers/plans/2026-10-13-global-plugins.md +56 -0
- package/manual/docs/superpowers/plans/2026-10-13-tui-readable-sessions.md +21 -0
- package/manual/docs/superpowers/reviews/2026-10-13-0.5.0-followup-review.md +4 -1
- package/manual/docs/superpowers/reviews/2026-10-13-0.5.3-review.md +28 -0
- package/manual/docs/superpowers/reviews/2026-10-13-command-shortcuts-review.md +70 -0
- package/manual/docs/superpowers/reviews/2026-10-13-tui-sessions-review.md +55 -0
- package/manual/docs/superpowers/specs/2026-10-12-workflow-variation-design.md +1 -1
- package/manual/docs/superpowers/specs/2026-10-13-command-shortcuts-design.md +56 -0
- package/manual/docs/superpowers/specs/2026-10-13-issue-4-workflow-menu.md +51 -0
- package/manual/docs/superpowers/specs/2026-10-13-issue-5-results-and-history.md +20 -0
- package/manual/docs/terminal-commands.md +72 -0
- package/manual/docs/verification.md +56 -1
- package/manual/packages/core/README.md +5 -1
- package/manual/packages/core/package.json +2 -1
- package/manual/packages/core/src/application.js +203 -57
- package/manual/packages/core/src/development-watch-worker.js +10 -1
- package/manual/packages/core/src/development.js +1 -1
- package/manual/packages/core/src/export-snapshot.js +20 -1
- package/manual/packages/core/src/plugin-catalog.js +42 -0
- package/manual/packages/core/src/version.js +1 -1
- package/manual/packages/fst-cli/README.md +6 -0
- package/manual/packages/fst-cli/bin/fst.js +7 -6
- package/manual/packages/fst-cli/package.json +1 -1
- package/manual/packages/fst-cli/src/development.js +6 -1
- package/manual/packages/fst-cli/src/terminal/command-menu.js +191 -0
- package/manual/packages/fst-cli/src/terminal/navigation.js +6 -3
- package/manual/packages/fst-cli/src/terminal/presentation.js +4 -3
- package/manual/packages/fst-cli/src/terminal/run-feed.js +69 -13
- package/manual/packages/fst-cli/src/terminal/run-presentation.js +55 -12
- package/manual/packages/fst-cli/src/terminal/run-viewer.js +26 -10
- package/manual/packages/fst-cli/src/terminal/session-history.js +82 -0
- package/manual/packages/fst-cli/src/terminal/session.js +153 -43
- package/manual/packages/fst-cli/src/terminal/view.js +74 -16
- package/manual/packages/fst-cli/src/terminal/workflow-menu.js +15 -15
- package/manual/packages/fst-devtools/package.json +2 -2
- package/manual/packages/fst-devtools/src/documentation.js +2 -1
- package/manual/packages/fst-devtools/src/plugin-tools.js +1 -1
- package/manual/packages/fst-logs/README.md +23 -2
- package/manual/packages/fst-logs/package.json +2 -1
- package/manual/packages/fst-logs/src/file-identity.js +23 -0
- package/manual/packages/fst-logs/src/markdown-log.js +4 -3
- package/manual/packages/fst-logs/src/run-logs.js +3 -2
- package/manual/packages/fst-logs/src/session-history.js +180 -0
- package/manual/packages/fst-platform/README.md +15 -0
- package/manual/packages/fst-platform/package.json +4 -3
- package/manual/packages/fst-platform/src/process.js +15 -8
- package/manual/packages/fst-platform/src/shell.js +103 -0
- package/manual/packages/fst-plugin/package.json +1 -1
- package/manual/packages/fst-plugin/src/contracts.js +6 -2
- package/manual/packages/fst-plugin/src/host.js +31 -23
- package/manual/packages/fst-workflow/package.json +1 -1
- package/manual/packages/fst-workflow/src/engine.js +1 -1
- package/manual/packages/fst-workspace/README.md +5 -0
- package/manual/packages/fst-workspace/package.json +3 -1
- package/manual/packages/fst-workspace/src/plugin-registry.js +58 -0
- package/manual/packages/fst-workspace/src/plugins.js +7 -4
- package/manual/packages/fst-workspace/src/shortcuts.js +119 -0
- package/manual/packages/fst-workspace/src/workflows.js +5 -3
- package/manual/packages/pack/index.js +1 -1
- package/manual/packages/pack/package.json +3 -3
- package/manual/packages/pack/runtime-cache.js +26 -0
- package/manual/packages/pack/runtime.js +6 -10
- package/manual/plugins/commands/LICENSE +21 -0
- package/manual/plugins/commands/README.md +41 -0
- package/manual/plugins/commands/index.js +94 -0
- package/manual/plugins/commands/package.json +17 -0
- package/node_modules/@mytools/commands/LICENSE +21 -0
- package/node_modules/@mytools/commands/README.md +41 -0
- package/node_modules/@mytools/commands/index.js +94 -0
- package/node_modules/@mytools/commands/package.json +17 -0
- package/node_modules/@mytools/core/README.md +5 -1
- package/node_modules/@mytools/core/package.json +2 -1
- package/node_modules/@mytools/core/src/application.js +203 -57
- package/node_modules/@mytools/core/src/development-watch-worker.js +10 -1
- package/node_modules/@mytools/core/src/development.js +1 -1
- package/node_modules/@mytools/core/src/export-snapshot.js +20 -1
- package/node_modules/@mytools/core/src/plugin-catalog.js +42 -0
- package/node_modules/@mytools/core/src/version.js +1 -1
- package/node_modules/@mytools/fst-cli/README.md +6 -0
- package/node_modules/@mytools/fst-cli/bin/fst.js +7 -6
- package/node_modules/@mytools/fst-cli/package.json +1 -1
- package/node_modules/@mytools/fst-cli/src/development.js +6 -1
- package/node_modules/@mytools/fst-cli/src/terminal/command-menu.js +191 -0
- package/node_modules/@mytools/fst-cli/src/terminal/navigation.js +6 -3
- package/node_modules/@mytools/fst-cli/src/terminal/presentation.js +4 -3
- package/node_modules/@mytools/fst-cli/src/terminal/run-feed.js +69 -13
- package/node_modules/@mytools/fst-cli/src/terminal/run-presentation.js +55 -12
- package/node_modules/@mytools/fst-cli/src/terminal/run-viewer.js +26 -10
- package/node_modules/@mytools/fst-cli/src/terminal/session-history.js +82 -0
- package/node_modules/@mytools/fst-cli/src/terminal/session.js +153 -43
- package/node_modules/@mytools/fst-cli/src/terminal/view.js +74 -16
- package/node_modules/@mytools/fst-cli/src/terminal/workflow-menu.js +15 -15
- package/node_modules/@mytools/fst-devtools/package.json +2 -2
- package/node_modules/@mytools/fst-devtools/src/documentation.js +2 -1
- package/node_modules/@mytools/fst-devtools/src/plugin-tools.js +1 -1
- package/node_modules/@mytools/fst-logs/README.md +23 -2
- package/node_modules/@mytools/fst-logs/package.json +2 -1
- package/node_modules/@mytools/fst-logs/src/file-identity.js +23 -0
- package/node_modules/@mytools/fst-logs/src/markdown-log.js +4 -3
- package/node_modules/@mytools/fst-logs/src/run-logs.js +3 -2
- package/node_modules/@mytools/fst-logs/src/session-history.js +180 -0
- package/node_modules/@mytools/fst-platform/README.md +15 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/LICENSE +21 -0
- package/node_modules/{undici/docs/docs/index.md → @mytools/fst-platform/node_modules/undici/README.md} +85 -137
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Agent.md +84 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Client.md +288 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Connector.md +115 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ContentType.md +57 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Cookies.md +128 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Debug.md +62 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +317 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Dispatcher.md +1393 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Errors.md +49 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/EventSource.md +45 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Fetch.md +60 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockClient.md +81 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/MockPool.md +555 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Pool.md +84 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/Util.md +25 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/docs/docs/best-practices/crawling.md +1 -3
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/docs/docs/best-practices/undici-vs-builtin-fetch.md +8 -10
- package/node_modules/@mytools/fst-platform/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/index-fetch.js +65 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/index.d.ts +3 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/index.js +234 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-connect.js +110 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-pipeline.js +252 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-request.js +214 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-stream.js +209 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/api-upgrade.js +111 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/index.js +7 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/api/readable.js +580 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/cache/memory-cache-store.js +3 -3
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/cache/sqlite-cache-store.js +1 -3
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/connect.js +153 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/constants.js +143 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/errors.js +477 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/request.js +485 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/symbols.js +75 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/tree.js +160 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/core/util.js +992 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/agent.js +158 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client-h1.js +1746 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client-h2.js +1060 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/client.js +668 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/h2c-client.js +4 -4
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/pool.js +118 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/round-robin-pool.js +10 -32
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/dispatcher/socks5-proxy-agent.js +63 -153
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/global.js +59 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/cache-handler.js +7 -49
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/cache-revalidation-handler.js +0 -10
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/decorator-handler.js +67 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/handler/deduplication-handler.js +10 -29
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/redirect-handler.js +238 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/retry-handler.js +504 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/handler/wrap-handler.js +105 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/cache.js +26 -79
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/decompress.js +3 -13
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/interceptor/deduplicate.js +4 -5
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/dns.js +571 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/response-error.js +95 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-agent.js +232 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/mock-call-history.js +1 -1
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/mock-utils.js +486 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-agent.js +7 -25
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-recorder.js +3 -38
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/cache.js +10 -92
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/util/promise.js +28 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/runtime-features.js +34 -3
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/util/timers.js +425 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/cache.js +864 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cache/util.js +45 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/index.js +199 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/parse.js +314 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/cookies/util.js +352 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/eventsource/util.js +29 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/body.js +509 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/formdata.js +259 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/headers.js +719 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/index.js +2413 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/request.js +1115 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/response.js +641 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/fetch/util.js +1522 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/infra/index.js +1 -16
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/webidl/index.js +21 -7
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/connection.js +339 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/events.js +331 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/frame.js +133 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/receiver.js +507 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/websocket/stream/websocketerror.js +10 -13
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/websocket/stream/websocketstream.js +14 -29
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/lib/web/websocket/websocket.js +758 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/package.json +152 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/scripts/strip-comments.js +10 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/README.md +6 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/agent.d.ts +32 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/api.d.ts +43 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/cache.d.ts +36 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/client.d.ts +139 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/connector.d.ts +36 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/content-type.d.ts +21 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/cookies.d.ts +30 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/dispatcher.d.ts +275 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/errors.d.ts +177 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/eventsource.d.ts +66 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/fetch.d.ts +231 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/formdata.d.ts +114 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/global-origin.d.ts +7 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/h2c-client.d.ts +6 -6
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/handlers.d.ts +14 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/header.d.ts +160 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/index.d.ts +91 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/interceptors.d.ts +82 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-agent.d.ts +68 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-client.d.ts +27 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-interceptor.d.ts +94 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/patch.d.ts +29 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/pool.d.ts +41 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/proxy-agent.d.ts +29 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/readable.d.ts +68 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/round-robin-pool.d.ts +2 -0
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/snapshot-agent.d.ts +0 -4
- package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/socks5-proxy-agent.d.ts +2 -4
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/util.d.ts +18 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/webidl.d.ts +347 -0
- package/node_modules/@mytools/fst-platform/node_modules/undici/types/websocket.d.ts +188 -0
- package/node_modules/@mytools/fst-platform/package.json +4 -3
- package/node_modules/@mytools/fst-platform/src/process.js +15 -8
- package/node_modules/@mytools/fst-platform/src/shell.js +103 -0
- package/node_modules/@mytools/fst-plugin/package.json +1 -1
- package/node_modules/@mytools/fst-plugin/src/contracts.js +6 -2
- package/node_modules/@mytools/fst-plugin/src/host.js +31 -23
- package/node_modules/@mytools/fst-workflow/package.json +1 -1
- package/node_modules/@mytools/fst-workflow/src/engine.js +1 -1
- package/node_modules/@mytools/fst-workspace/README.md +5 -0
- package/node_modules/@mytools/fst-workspace/package.json +3 -1
- package/node_modules/@mytools/fst-workspace/src/plugin-registry.js +58 -0
- package/node_modules/@mytools/fst-workspace/src/plugins.js +7 -4
- package/node_modules/@mytools/fst-workspace/src/shortcuts.js +119 -0
- package/node_modules/@mytools/fst-workspace/src/workflows.js +5 -3
- package/node_modules/@mytools/pack/index.js +1 -1
- package/node_modules/@mytools/pack/package.json +3 -3
- package/node_modules/@mytools/pack/runtime-cache.js +26 -0
- package/node_modules/@mytools/pack/runtime.js +6 -10
- package/node_modules/@mytools/web/public/THIRD_PARTY_NOTICES.txt +1246 -1232
- package/node_modules/@npmcli/agent/lib/agents.js +0 -10
- package/node_modules/@npmcli/agent/package.json +12 -11
- package/node_modules/@npmcli/arborist/README.md +2 -2
- package/node_modules/@npmcli/arborist/bin/index.js +2 -1
- package/node_modules/@npmcli/arborist/bin/shrinkwrap.js +7 -0
- package/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +25 -159
- package/node_modules/@npmcli/arborist/lib/arborist/isolated-reifier.js +49 -11
- package/node_modules/@npmcli/arborist/lib/arborist/load-actual.js +0 -67
- package/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +37 -5
- package/node_modules/@npmcli/arborist/lib/arborist/rebuild.js +8 -15
- package/node_modules/@npmcli/arborist/lib/arborist/reify.js +42 -59
- package/node_modules/@npmcli/arborist/lib/consistent-resolve.js +1 -1
- package/node_modules/@npmcli/arborist/lib/diff.js +22 -17
- package/node_modules/@npmcli/arborist/lib/edge.js +2 -22
- package/node_modules/@npmcli/arborist/lib/index.js +0 -2
- package/node_modules/@npmcli/arborist/lib/isolated-classes.js +1 -4
- package/node_modules/@npmcli/arborist/lib/node.js +9 -13
- package/node_modules/@npmcli/arborist/lib/place-dep.js +0 -6
- package/node_modules/@npmcli/arborist/lib/printable.js +5 -0
- package/node_modules/@npmcli/arborist/lib/shrinkwrap.js +32 -55
- package/node_modules/@npmcli/arborist/package.json +26 -32
- package/node_modules/@npmcli/fs/lib/move-file.js +5 -5
- package/node_modules/@npmcli/fs/package.json +5 -5
- package/node_modules/@npmcli/git/package.json +12 -13
- package/node_modules/@npmcli/installed-package-contents/package.json +7 -7
- package/node_modules/@npmcli/map-workspaces/package.json +7 -7
- package/node_modules/@npmcli/metavuln-calculator/package.json +16 -10
- package/node_modules/@npmcli/name-from-folder/package.json +16 -13
- package/node_modules/@npmcli/node-gyp/package.json +5 -5
- package/node_modules/@npmcli/package-json/lib/index.js +1 -2
- package/node_modules/@npmcli/package-json/lib/normalize.js +22 -23
- package/node_modules/@npmcli/package-json/package.json +10 -11
- package/node_modules/@npmcli/promise-spawn/README.md +2 -1
- package/node_modules/@npmcli/promise-spawn/package.json +5 -5
- package/node_modules/@npmcli/redact/package.json +4 -4
- package/node_modules/@npmcli/run-script/lib/is-server-package.js +11 -0
- package/node_modules/@npmcli/run-script/lib/make-spawn-args.js +6 -5
- package/node_modules/@npmcli/run-script/lib/run-script-pkg.js +13 -4
- package/node_modules/@npmcli/run-script/lib/run-script.js +2 -1
- package/node_modules/@npmcli/run-script/package.json +11 -12
- package/node_modules/@sigstore/bundle/README.md +1 -1
- package/node_modules/@sigstore/bundle/dist/error.js +0 -1
- package/node_modules/@sigstore/bundle/package.json +2 -2
- package/node_modules/@sigstore/core/README.md +1 -1
- package/node_modules/@sigstore/core/dist/asn1/length.js +1 -12
- package/node_modules/@sigstore/core/dist/asn1/obj.js +7 -25
- package/node_modules/@sigstore/core/dist/asn1/parse.js +5 -24
- package/node_modules/@sigstore/core/package.json +2 -2
- package/node_modules/@sigstore/sign/README.md +1 -1
- package/node_modules/@sigstore/sign/dist/signer/fulcio/ephemeral.js +1 -1
- package/node_modules/@sigstore/sign/package.json +9 -9
- package/node_modules/@sigstore/tuf/README.md +1 -1
- package/node_modules/@sigstore/tuf/package.json +4 -4
- package/node_modules/@sigstore/tuf/seeds.json +1 -1
- package/node_modules/@sigstore/verify/README.md +1 -1
- package/node_modules/@sigstore/verify/dist/bundle/dsse.d.ts +0 -1
- package/node_modules/@sigstore/verify/dist/bundle/dsse.js +0 -6
- package/node_modules/@sigstore/verify/dist/bundle/message.d.ts +0 -1
- package/node_modules/@sigstore/verify/dist/bundle/message.js +0 -5
- package/node_modules/@sigstore/verify/dist/policy.d.ts +1 -1
- package/node_modules/@sigstore/verify/dist/policy.js +2 -0
- package/node_modules/@sigstore/verify/dist/shared.types.d.ts +1 -6
- package/node_modules/@sigstore/verify/dist/tlog/checkpoint.js +3 -17
- package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.js +4 -4
- package/node_modules/@sigstore/verify/dist/tlog/index.js +1 -13
- package/node_modules/@sigstore/verify/dist/tlog/merkle.js +1 -12
- package/node_modules/@sigstore/verify/dist/verifier.js +5 -13
- package/node_modules/@sigstore/verify/package.json +5 -5
- package/node_modules/@tufjs/models/package.json +3 -3
- package/node_modules/abbrev/package.json +8 -9
- package/node_modules/agent-base/dist/helpers.d.ts +5 -0
- package/node_modules/agent-base/dist/helpers.d.ts.map +1 -1
- package/node_modules/agent-base/dist/helpers.js +34 -5
- package/node_modules/agent-base/dist/helpers.js.map +1 -1
- package/node_modules/agent-base/dist/index.d.ts +5 -1
- package/node_modules/agent-base/dist/index.d.ts.map +1 -1
- package/node_modules/agent-base/dist/index.js +40 -8
- package/node_modules/agent-base/dist/index.js.map +1 -1
- package/node_modules/agent-base/package.json +12 -12
- package/node_modules/bin-links/README.md +4 -5
- package/node_modules/bin-links/lib/fix-bin.js +1 -3
- package/node_modules/bin-links/lib/index.js +16 -8
- package/node_modules/bin-links/lib/link-mans.js +53 -0
- package/node_modules/bin-links/package.json +12 -11
- package/node_modules/cacache/lib/content/write.js +0 -2
- package/node_modules/cacache/lib/entry-index.js +0 -3
- package/node_modules/cacache/lib/rm.js +0 -1
- package/node_modules/cacache/lib/util/tmp.js +1 -5
- package/node_modules/cacache/lib/verify.js +2 -2
- package/node_modules/cacache/package.json +7 -7
- package/node_modules/cmd-shim/lib/index.js +32 -67
- package/node_modules/cmd-shim/package.json +5 -5
- package/node_modules/hosted-git-info/README.md +1 -1
- package/node_modules/hosted-git-info/lib/parse-url.js +3 -1
- package/node_modules/hosted-git-info/package.json +4 -4
- package/node_modules/http-proxy-agent/dist/index.d.ts +5 -8
- package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -1
- package/node_modules/http-proxy-agent/dist/index.js +42 -26
- package/node_modules/http-proxy-agent/dist/index.js.map +1 -1
- package/node_modules/http-proxy-agent/package.json +14 -15
- package/node_modules/https-proxy-agent/dist/index.d.ts +5 -9
- package/node_modules/https-proxy-agent/dist/index.d.ts.map +1 -1
- package/node_modules/https-proxy-agent/dist/index.js +44 -98
- package/node_modules/https-proxy-agent/dist/index.js.map +1 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +3 -0
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts.map +1 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +10 -3
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -1
- package/node_modules/https-proxy-agent/package.json +15 -16
- package/node_modules/ignore-walk/package.json +4 -4
- package/node_modules/ini/package.json +5 -5
- package/node_modules/ip-address/README.md +70 -70
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/dist/v6/constants.d.ts +3 -0
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/json-parse-even-better-errors/lib/index.js +1 -3
- package/node_modules/json-parse-even-better-errors/package.json +17 -13
- package/node_modules/make-fetch-happen/package.json +11 -11
- package/node_modules/minipass-fetch/package.json +4 -4
- package/node_modules/node-gyp/.release-please-manifest.json +1 -1
- package/node_modules/node-gyp/CHANGELOG.md +0 -102
- package/node_modules/node-gyp/README.md +2 -3
- package/node_modules/node-gyp/eslint.config.js +1 -4
- package/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
- package/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +19 -14
- package/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +2 -7
- package/node_modules/node-gyp/gyp/pyproject.toml +1 -1
- package/node_modules/node-gyp/lib/build.js +6 -18
- package/node_modules/node-gyp/lib/create-config-gypi.js +0 -5
- package/node_modules/node-gyp/lib/node-gyp.js +2 -9
- package/node_modules/node-gyp/lib/rebuild.js +3 -3
- package/node_modules/node-gyp/package.json +9 -11
- package/node_modules/nopt/README.md +4 -2
- package/node_modules/nopt/lib/debug.js +5 -0
- package/node_modules/nopt/lib/nopt-lib.js +43 -7
- package/node_modules/nopt/lib/nopt.js +4 -2
- package/node_modules/nopt/lib/type-defs.js +13 -8
- package/node_modules/nopt/package.json +17 -15
- package/node_modules/npm-bundled/package.json +6 -6
- package/node_modules/npm-install-checks/package.json +5 -5
- package/node_modules/npm-normalize-package-bin/package.json +16 -13
- package/node_modules/npm-package-arg/package.json +7 -7
- package/node_modules/npm-packlist/README.md +30 -45
- package/node_modules/npm-packlist/lib/index.js +47 -115
- package/node_modules/npm-packlist/package.json +8 -10
- package/node_modules/npm-pick-manifest/package.json +19 -15
- package/node_modules/npm-registry-fetch/lib/errors.js +3 -8
- package/node_modules/npm-registry-fetch/package.json +12 -12
- package/node_modules/pacote/lib/dir.js +5 -60
- package/node_modules/pacote/lib/fetcher.js +0 -4
- package/node_modules/pacote/lib/git.js +3 -11
- package/node_modules/pacote/lib/util/add-git-sha.js +1 -1
- package/node_modules/pacote/package.json +18 -19
- package/node_modules/parse-conflict-json/package.json +6 -6
- package/node_modules/proc-log/package.json +4 -4
- package/node_modules/read-cmd-shim/lib/index.js +1 -1
- package/node_modules/read-cmd-shim/package.json +18 -14
- package/node_modules/sigstore/README.md +1 -1
- package/node_modules/sigstore/package.json +10 -10
- package/node_modules/socks-proxy-agent/dist/index.d.ts +3 -1
- package/node_modules/socks-proxy-agent/dist/index.d.ts.map +1 -1
- package/node_modules/socks-proxy-agent/dist/index.js +43 -17
- package/node_modules/socks-proxy-agent/dist/index.js.map +1 -1
- package/node_modules/socks-proxy-agent/package.json +15 -15
- package/node_modules/ssri/package.json +4 -4
- package/node_modules/tuf-js/dist/config.d.ts +2 -2
- package/node_modules/tuf-js/dist/fetcher.d.ts +4 -4
- package/node_modules/tuf-js/dist/fetcher.js +16 -55
- package/node_modules/tuf-js/dist/updater.js +2 -2
- package/node_modules/tuf-js/package.json +8 -8
- package/node_modules/undici/README.md +72 -405
- package/node_modules/undici/docs/docs/api/Agent.md +41 -252
- package/node_modules/undici/docs/docs/api/BalancedPool.md +48 -246
- package/node_modules/undici/docs/docs/api/CacheStorage.md +13 -171
- package/node_modules/undici/docs/docs/api/Client.md +139 -395
- package/node_modules/undici/docs/docs/api/Connector.md +35 -118
- package/node_modules/undici/docs/docs/api/ContentType.md +25 -65
- package/node_modules/undici/docs/docs/api/Cookies.md +47 -125
- package/node_modules/undici/docs/docs/api/Debug.md +31 -47
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +97 -409
- package/node_modules/undici/docs/docs/api/DispatchInterceptor.md +60 -0
- package/node_modules/undici/docs/docs/api/Dispatcher.md +1011 -500
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +96 -105
- package/node_modules/undici/docs/docs/api/Errors.md +28 -528
- package/node_modules/undici/docs/docs/api/EventSource.md +13 -326
- package/node_modules/undici/docs/docs/api/Fetch.md +24 -693
- package/node_modules/undici/docs/docs/api/MockAgent.md +264 -346
- package/node_modules/undici/docs/docs/api/MockClient.md +31 -153
- package/node_modules/undici/docs/docs/api/MockErrors.md +5 -56
- package/node_modules/undici/docs/docs/api/MockPool.md +253 -324
- package/node_modules/undici/docs/docs/api/Pool.md +41 -235
- package/node_modules/undici/docs/docs/api/PoolStats.md +13 -119
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +81 -198
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +58 -238
- package/node_modules/undici/docs/docs/api/RetryAgent.md +28 -119
- package/node_modules/undici/docs/docs/api/RetryHandler.md +78 -161
- package/node_modules/undici/docs/docs/api/Util.md +11 -68
- package/node_modules/undici/docs/docs/api/WebSocket.md +24 -509
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +33 -101
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -2
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +2 -58
- package/node_modules/undici/docs/docs/best-practices/proxy.md +1 -3
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -45
- package/node_modules/undici/index-fetch.js +4 -34
- package/node_modules/undici/index.d.ts +1 -1
- package/node_modules/undici/index.js +20 -87
- package/node_modules/undici/lib/api/abort-signal.js +0 -2
- package/node_modules/undici/lib/api/api-connect.js +11 -15
- package/node_modules/undici/lib/api/api-pipeline.js +19 -33
- package/node_modules/undici/lib/api/api-request.js +59 -89
- package/node_modules/undici/lib/api/api-stream.js +64 -114
- package/node_modules/undici/lib/api/api-upgrade.js +13 -26
- package/node_modules/undici/lib/api/readable.js +87 -317
- package/node_modules/undici/lib/api/util.js +93 -0
- package/node_modules/undici/lib/core/connect.js +125 -77
- package/node_modules/undici/lib/core/constants.js +9 -11
- package/node_modules/undici/lib/core/diagnostics.js +129 -154
- package/node_modules/undici/lib/core/errors.js +50 -122
- package/node_modules/undici/lib/core/request.js +87 -172
- package/node_modules/undici/lib/core/symbols.js +2 -14
- package/node_modules/undici/lib/core/tree.js +2 -10
- package/node_modules/undici/lib/core/util.js +190 -481
- package/node_modules/undici/lib/dispatcher/agent.js +35 -83
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +38 -46
- package/node_modules/undici/lib/dispatcher/client-h1.js +199 -492
- package/node_modules/undici/lib/dispatcher/client-h2.js +380 -1409
- package/node_modules/undici/lib/dispatcher/client.js +130 -253
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +52 -50
- package/node_modules/undici/lib/dispatcher/dispatcher.js +24 -17
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +45 -75
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +50 -68
- package/node_modules/undici/lib/dispatcher/pool-base.js +54 -153
- package/node_modules/undici/lib/dispatcher/pool-stats.js +34 -0
- package/node_modules/undici/lib/dispatcher/pool.js +16 -135
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +41 -175
- package/node_modules/undici/lib/dispatcher/retry-agent.js +0 -3
- package/node_modules/undici/lib/global.js +9 -59
- package/node_modules/undici/lib/handler/decorator-handler.js +15 -43
- package/node_modules/undici/lib/handler/redirect-handler.js +116 -127
- package/node_modules/undici/lib/handler/retry-handler.js +182 -398
- package/node_modules/undici/lib/interceptor/dns.js +47 -254
- package/node_modules/undici/lib/interceptor/dump.js +56 -32
- package/node_modules/undici/lib/interceptor/redirect-interceptor.js +21 -0
- package/node_modules/undici/lib/interceptor/redirect.js +14 -11
- package/node_modules/undici/lib/interceptor/response-error.js +22 -31
- package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/undici/lib/llhttp/constants.js +193 -446
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -11
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -11
- package/node_modules/undici/lib/llhttp/utils.js +12 -9
- package/node_modules/undici/lib/mock/mock-agent.js +22 -106
- package/node_modules/undici/lib/mock/mock-client.js +4 -13
- package/node_modules/undici/lib/mock/mock-errors.js +2 -3
- package/node_modules/undici/lib/mock/mock-interceptor.js +13 -33
- package/node_modules/undici/lib/mock/mock-pool.js +4 -13
- package/node_modules/undici/lib/mock/mock-symbols.js +1 -10
- package/node_modules/undici/lib/mock/mock-utils.js +51 -404
- package/node_modules/undici/lib/mock/pluralizer.js +29 -0
- package/node_modules/undici/lib/util/timers.js +9 -11
- package/node_modules/undici/lib/web/cache/cache.js +51 -63
- package/node_modules/undici/lib/web/cache/cachestorage.js +7 -13
- package/node_modules/undici/lib/web/cache/symbols.js +5 -0
- package/node_modules/undici/lib/web/cookies/index.js +18 -45
- package/node_modules/undici/lib/web/cookies/parse.js +149 -157
- package/node_modules/undici/lib/web/cookies/util.js +2 -4
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +9 -37
- package/node_modules/undici/lib/web/eventsource/eventsource.js +64 -108
- package/node_modules/undici/lib/web/eventsource/util.js +5 -28
- package/node_modules/undici/lib/web/fetch/body.js +148 -173
- package/node_modules/undici/lib/web/fetch/constants.js +6 -13
- package/node_modules/undici/lib/web/fetch/data-url.js +167 -19
- package/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +46 -0
- package/node_modules/undici/lib/web/fetch/file.js +126 -0
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +117 -229
- package/node_modules/undici/lib/web/fetch/formdata.js +65 -85
- package/node_modules/undici/lib/web/fetch/headers.js +108 -143
- package/node_modules/undici/lib/web/fetch/index.js +446 -627
- package/node_modules/undici/lib/web/fetch/request.js +115 -217
- package/node_modules/undici/lib/web/fetch/response.js +82 -110
- package/node_modules/undici/lib/web/fetch/symbols.js +9 -0
- package/node_modules/undici/lib/web/fetch/util.js +393 -291
- package/node_modules/undici/lib/web/fetch/webidl.js +695 -0
- package/node_modules/undici/lib/web/fileapi/encoding.js +290 -0
- package/node_modules/undici/lib/web/fileapi/filereader.js +344 -0
- package/node_modules/undici/lib/web/fileapi/progressevent.js +78 -0
- package/node_modules/undici/lib/web/fileapi/symbols.js +10 -0
- package/node_modules/undici/lib/web/fileapi/util.js +391 -0
- package/node_modules/undici/lib/web/websocket/connection.js +160 -139
- package/node_modules/undici/lib/web/websocket/constants.js +10 -70
- package/node_modules/undici/lib/web/websocket/events.js +30 -49
- package/node_modules/undici/lib/web/websocket/frame.js +20 -51
- package/node_modules/undici/lib/web/websocket/receiver.js +87 -83
- package/node_modules/undici/lib/web/websocket/sender.js +13 -18
- package/node_modules/undici/lib/web/websocket/symbols.js +12 -0
- package/node_modules/undici/lib/web/websocket/util.js +90 -115
- package/node_modules/undici/lib/web/websocket/websocket.js +171 -359
- package/node_modules/undici/package.json +57 -49
- package/node_modules/undici/scripts/strip-comments.js +1 -3
- package/node_modules/undici/types/agent.d.ts +13 -12
- package/node_modules/undici/types/api.d.ts +26 -26
- package/node_modules/undici/types/balanced-pool.d.ts +12 -13
- package/node_modules/undici/types/client.d.ts +39 -98
- package/node_modules/undici/types/connector.d.ts +2 -5
- package/node_modules/undici/types/cookies.d.ts +1 -3
- package/node_modules/undici/types/diagnostics-channel.d.ts +11 -20
- package/node_modules/undici/types/dispatcher.d.ts +139 -136
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +3 -4
- package/node_modules/undici/types/errors.d.ts +54 -86
- package/node_modules/undici/types/eventsource.d.ts +4 -9
- package/node_modules/undici/types/fetch.d.ts +25 -51
- package/node_modules/undici/types/file.d.ts +39 -0
- package/node_modules/undici/types/filereader.d.ts +54 -0
- package/node_modules/undici/types/formdata.d.ts +7 -7
- package/node_modules/undici/types/global-dispatcher.d.ts +4 -4
- package/node_modules/undici/types/global-origin.d.ts +5 -5
- package/node_modules/undici/types/handlers.d.ts +9 -10
- package/node_modules/undici/types/header.d.ts +1 -162
- package/node_modules/undici/types/index.d.ts +47 -69
- package/node_modules/undici/types/interceptors.d.ts +12 -62
- package/node_modules/undici/types/mock-agent.d.ts +27 -46
- package/node_modules/undici/types/mock-client.d.ts +4 -6
- package/node_modules/undici/types/mock-errors.d.ts +3 -3
- package/node_modules/undici/types/mock-interceptor.d.ts +21 -26
- package/node_modules/undici/types/mock-pool.d.ts +4 -6
- package/node_modules/undici/types/patch.d.ts +4 -0
- package/node_modules/undici/types/pool-stats.d.ts +8 -8
- package/node_modules/undici/types/pool.d.ts +14 -14
- package/node_modules/undici/types/proxy-agent.d.ts +6 -13
- package/node_modules/undici/types/readable.d.ts +16 -19
- package/node_modules/undici/types/retry-agent.d.ts +1 -1
- package/node_modules/undici/types/retry-handler.d.ts +9 -18
- package/node_modules/undici/types/util.d.ts +3 -3
- package/node_modules/undici/types/webidl.d.ts +32 -156
- package/node_modules/undici/types/websocket.d.ts +10 -48
- package/node_modules/validate-npm-package-name/package.json +4 -4
- package/node_modules/which/package.json +4 -4
- package/node_modules/write-file-atomic/package.json +4 -4
- package/package.json +58 -60
- package/node_modules/@npmcli/arborist/lib/npm-extension.js +0 -237
- package/node_modules/@npmcli/arborist/lib/package-extensions.js +0 -236
- package/node_modules/@npmcli/arborist/lib/patch.js +0 -111
- package/node_modules/@npmcli/arborist/lib/patched-dependencies.js +0 -168
- package/node_modules/cacache/lib/util/cache-dir.js +0 -29
- package/node_modules/diff/CONTRIBUTING.md +0 -28
- package/node_modules/diff/LICENSE +0 -29
- package/node_modules/diff/README.md +0 -388
- package/node_modules/diff/dist/diff.js +0 -1782
- package/node_modules/diff/dist/diff.min.js +0 -1
- package/node_modules/diff/eslint.config.mjs +0 -182
- package/node_modules/diff/libcjs/convert/dmp.d.ts +0 -8
- package/node_modules/diff/libcjs/convert/dmp.d.ts.map +0 -1
- package/node_modules/diff/libcjs/convert/dmp.js +0 -24
- package/node_modules/diff/libcjs/convert/xml.d.ts +0 -6
- package/node_modules/diff/libcjs/convert/xml.d.ts.map +0 -1
- package/node_modules/diff/libcjs/convert/xml.js +0 -34
- package/node_modules/diff/libcjs/diff/array.d.ts +0 -19
- package/node_modules/diff/libcjs/diff/array.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/array.js +0 -40
- package/node_modules/diff/libcjs/diff/base.d.ts +0 -20
- package/node_modules/diff/libcjs/diff/base.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/base.js +0 -265
- package/node_modules/diff/libcjs/diff/character.d.ts +0 -19
- package/node_modules/diff/libcjs/diff/character.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/character.js +0 -31
- package/node_modules/diff/libcjs/diff/css.d.ts +0 -18
- package/node_modules/diff/libcjs/diff/css.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/css.js +0 -34
- package/node_modules/diff/libcjs/diff/json.d.ts +0 -24
- package/node_modules/diff/libcjs/diff/json.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/json.js +0 -105
- package/node_modules/diff/libcjs/diff/line.d.ts +0 -24
- package/node_modules/diff/libcjs/diff/line.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/line.js +0 -89
- package/node_modules/diff/libcjs/diff/sentence.d.ts +0 -21
- package/node_modules/diff/libcjs/diff/sentence.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/sentence.js +0 -67
- package/node_modules/diff/libcjs/diff/word.d.ts +0 -35
- package/node_modules/diff/libcjs/diff/word.d.ts.map +0 -1
- package/node_modules/diff/libcjs/diff/word.js +0 -312
- package/node_modules/diff/libcjs/index.d.ts +0 -20
- package/node_modules/diff/libcjs/index.d.ts.map +0 -1
- package/node_modules/diff/libcjs/index.js +0 -64
- package/node_modules/diff/libcjs/package.json +0 -1
- package/node_modules/diff/libcjs/patch/apply.d.ts +0 -62
- package/node_modules/diff/libcjs/patch/apply.d.ts.map +0 -1
- package/node_modules/diff/libcjs/patch/apply.js +0 -267
- package/node_modules/diff/libcjs/patch/create.d.ts +0 -122
- package/node_modules/diff/libcjs/patch/create.d.ts.map +0 -1
- package/node_modules/diff/libcjs/patch/create.js +0 -251
- package/node_modules/diff/libcjs/patch/line-endings.d.ts +0 -17
- package/node_modules/diff/libcjs/patch/line-endings.d.ts.map +0 -1
- package/node_modules/diff/libcjs/patch/line-endings.js +0 -61
- package/node_modules/diff/libcjs/patch/parse.d.ts +0 -8
- package/node_modules/diff/libcjs/patch/parse.d.ts.map +0 -1
- package/node_modules/diff/libcjs/patch/parse.js +0 -150
- package/node_modules/diff/libcjs/patch/reverse.d.ts +0 -9
- package/node_modules/diff/libcjs/patch/reverse.d.ts.map +0 -1
- package/node_modules/diff/libcjs/patch/reverse.js +0 -37
- package/node_modules/diff/libcjs/types.d.ts +0 -213
- package/node_modules/diff/libcjs/types.d.ts.map +0 -1
- package/node_modules/diff/libcjs/types.js +0 -2
- package/node_modules/diff/libcjs/util/array.d.ts +0 -3
- package/node_modules/diff/libcjs/util/array.d.ts.map +0 -1
- package/node_modules/diff/libcjs/util/array.js +0 -21
- package/node_modules/diff/libcjs/util/distance-iterator.d.ts +0 -2
- package/node_modules/diff/libcjs/util/distance-iterator.d.ts.map +0 -1
- package/node_modules/diff/libcjs/util/distance-iterator.js +0 -40
- package/node_modules/diff/libcjs/util/params.d.ts +0 -4
- package/node_modules/diff/libcjs/util/params.d.ts.map +0 -1
- package/node_modules/diff/libcjs/util/params.js +0 -17
- package/node_modules/diff/libcjs/util/string.d.ts +0 -30
- package/node_modules/diff/libcjs/util/string.d.ts.map +0 -1
- package/node_modules/diff/libcjs/util/string.js +0 -200
- package/node_modules/diff/libesm/convert/dmp.d.ts +0 -8
- package/node_modules/diff/libesm/convert/dmp.d.ts.map +0 -1
- package/node_modules/diff/libesm/convert/dmp.js +0 -21
- package/node_modules/diff/libesm/convert/xml.d.ts +0 -6
- package/node_modules/diff/libesm/convert/xml.d.ts.map +0 -1
- package/node_modules/diff/libesm/convert/xml.js +0 -31
- package/node_modules/diff/libesm/diff/array.d.ts +0 -19
- package/node_modules/diff/libesm/diff/array.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/array.js +0 -16
- package/node_modules/diff/libesm/diff/base.d.ts +0 -20
- package/node_modules/diff/libesm/diff/base.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/base.js +0 -253
- package/node_modules/diff/libesm/diff/character.d.ts +0 -19
- package/node_modules/diff/libesm/diff/character.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/character.js +0 -7
- package/node_modules/diff/libesm/diff/css.d.ts +0 -18
- package/node_modules/diff/libesm/diff/css.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/css.js +0 -10
- package/node_modules/diff/libesm/diff/json.d.ts +0 -24
- package/node_modules/diff/libesm/diff/json.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/json.js +0 -78
- package/node_modules/diff/libesm/diff/line.d.ts +0 -24
- package/node_modules/diff/libesm/diff/line.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/line.js +0 -65
- package/node_modules/diff/libesm/diff/sentence.d.ts +0 -21
- package/node_modules/diff/libesm/diff/sentence.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/sentence.js +0 -43
- package/node_modules/diff/libesm/diff/word.d.ts +0 -35
- package/node_modules/diff/libesm/diff/word.d.ts.map +0 -1
- package/node_modules/diff/libesm/diff/word.js +0 -281
- package/node_modules/diff/libesm/index.d.ts +0 -20
- package/node_modules/diff/libesm/index.d.ts.map +0 -1
- package/node_modules/diff/libesm/index.js +0 -30
- package/node_modules/diff/libesm/package.json +0 -1
- package/node_modules/diff/libesm/patch/apply.d.ts +0 -62
- package/node_modules/diff/libesm/patch/apply.d.ts.map +0 -1
- package/node_modules/diff/libesm/patch/apply.js +0 -257
- package/node_modules/diff/libesm/patch/create.d.ts +0 -122
- package/node_modules/diff/libesm/patch/create.d.ts.map +0 -1
- package/node_modules/diff/libesm/patch/create.js +0 -228
- package/node_modules/diff/libesm/patch/line-endings.d.ts +0 -17
- package/node_modules/diff/libesm/patch/line-endings.d.ts.map +0 -1
- package/node_modules/diff/libesm/patch/line-endings.js +0 -44
- package/node_modules/diff/libesm/patch/parse.d.ts +0 -8
- package/node_modules/diff/libesm/patch/parse.d.ts.map +0 -1
- package/node_modules/diff/libesm/patch/parse.js +0 -147
- package/node_modules/diff/libesm/patch/reverse.d.ts +0 -9
- package/node_modules/diff/libesm/patch/reverse.d.ts.map +0 -1
- package/node_modules/diff/libesm/patch/reverse.js +0 -23
- package/node_modules/diff/libesm/types.d.ts +0 -213
- package/node_modules/diff/libesm/types.d.ts.map +0 -1
- package/node_modules/diff/libesm/types.js +0 -1
- package/node_modules/diff/libesm/util/array.d.ts +0 -3
- package/node_modules/diff/libesm/util/array.d.ts.map +0 -1
- package/node_modules/diff/libesm/util/array.js +0 -17
- package/node_modules/diff/libesm/util/distance-iterator.d.ts +0 -2
- package/node_modules/diff/libesm/util/distance-iterator.d.ts.map +0 -1
- package/node_modules/diff/libesm/util/distance-iterator.js +0 -37
- package/node_modules/diff/libesm/util/params.d.ts +0 -4
- package/node_modules/diff/libesm/util/params.d.ts.map +0 -1
- package/node_modules/diff/libesm/util/params.js +0 -14
- package/node_modules/diff/libesm/util/string.d.ts +0 -30
- package/node_modules/diff/libesm/util/string.d.ts.map +0 -1
- package/node_modules/diff/libesm/util/string.js +0 -184
- package/node_modules/diff/package.json +0 -130
- package/node_modules/diff/release-notes.md +0 -432
- package/node_modules/node-gyp/commitlint.config.mjs +0 -3
- package/node_modules/node-gyp/gyp/commitlint.config.js +0 -6
- package/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake_test.py +0 -105
- package/node_modules/node-gyp/zizmor.yml +0 -5
- package/node_modules/proxy-agent-negotiate/dist/index.d.ts +0 -14
- package/node_modules/proxy-agent-negotiate/dist/index.d.ts.map +0 -1
- package/node_modules/proxy-agent-negotiate/dist/index.js +0 -35
- package/node_modules/proxy-agent-negotiate/dist/index.js.map +0 -1
- package/node_modules/proxy-agent-negotiate/package.json +0 -47
- package/node_modules/undici/docs/docs/api/CacheStore.md +0 -360
- package/node_modules/undici/docs/docs/api/ClientStats.md +0 -93
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +0 -121
- package/node_modules/undici/docs/docs/api/H2CClient.md +0 -385
- package/node_modules/undici/docs/docs/api/Interceptors.md +0 -419
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -371
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -206
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +0 -239
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +0 -361
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +0 -256
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +0 -233
- package/node_modules/undici/docs/docs/getting-started.md +0 -281
- package/node_modules/undici/docs/docs/site.json +0 -125
- package/node_modules/undici/docs/docs/type-map.json +0 -79
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +0 -110
- package/node_modules/undici/types/dispatcher1-wrapper.d.ts +0 -7
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/core/socks5-client.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/core/socks5-utils.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/encoding/index.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/llhttp/constants.d.ts +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/llhttp/utils.d.ts +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/mock/snapshot-utils.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/date.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/util/stats.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/subresource-integrity/Readme.md +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/lib/web/subresource-integrity/subresource-integrity.js +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/cache-interceptor.d.ts +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/client-stats.d.ts +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/mock-call-history.d.ts +0 -0
- /package/node_modules/{undici → @mytools/fst-platform/node_modules/undici}/types/utility.d.ts +0 -0
|
@@ -1,61 +1,34 @@
|
|
|
1
1
|
# Dispatcher
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Extends: `events.EventEmitter`
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Dispatcher is the core API used to dispatch requests.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Requests are not guaranteed to be dispatched in order of invocation.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Instance Methods
|
|
10
10
|
|
|
11
|
-
`Dispatcher`
|
|
12
|
-
It extends [`EventEmitter`][] and defines the low-level [`dispatch()`][] contract
|
|
13
|
-
along with the higher-level [`request()`][], [`stream()`][], [`pipeline()`][],
|
|
14
|
-
[`connect()`][], and [`upgrade()`][] methods that every concrete dispatcher
|
|
15
|
-
provides.
|
|
11
|
+
### `Dispatcher.close([callback]): Promise`
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
[`destroy()`][] methods throw `Error: not implemented`. Concrete dispatchers such
|
|
19
|
-
as [`Client`][], [`Pool`][], [`BalancedPool`][], and [`Agent`][] implement the
|
|
20
|
-
contract and are what application code instantiates. Requests are not guaranteed
|
|
21
|
-
to be dispatched in the order in which they are invoked.
|
|
13
|
+
Closes the dispatcher and gracefully waits for enqueued requests to complete before resolving.
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
import { Dispatcher, Agent } from 'undici'
|
|
15
|
+
Arguments:
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
console.log(dispatcher instanceof Dispatcher) // true
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Class: `Dispatcher`
|
|
31
|
-
|
|
32
|
-
<!-- YAML
|
|
33
|
-
added: v4.0.0
|
|
34
|
-
-->
|
|
35
|
-
|
|
36
|
-
* Extends: {EventEmitter}
|
|
37
|
-
|
|
38
|
-
Base dispatcher class. Concrete dispatchers extend it and implement the
|
|
39
|
-
[`dispatch()`][] method on which the other request helpers are built.
|
|
40
|
-
|
|
41
|
-
### `dispatcher.close([callback])`
|
|
17
|
+
* **callback** `(error: Error | null, data: null) => void` (optional)
|
|
42
18
|
|
|
43
|
-
|
|
44
|
-
added: v4.0.0
|
|
45
|
-
-->
|
|
19
|
+
Returns: `void | Promise<null>` - Only returns a `Promise` if no `callback` argument was passed
|
|
46
20
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
21
|
+
```js
|
|
22
|
+
dispatcher.close() // -> Promise
|
|
23
|
+
dispatcher.close(() => {}) // -> void
|
|
24
|
+
```
|
|
51
25
|
|
|
52
|
-
|
|
53
|
-
before resolving or invoking `callback`.
|
|
26
|
+
#### Example - Request resolves before Client closes
|
|
54
27
|
|
|
55
|
-
```
|
|
56
|
-
import { createServer } from '
|
|
28
|
+
```js
|
|
29
|
+
import { createServer } from 'http'
|
|
57
30
|
import { Client } from 'undici'
|
|
58
|
-
import { once } from '
|
|
31
|
+
import { once } from 'events'
|
|
59
32
|
|
|
60
33
|
const server = createServer((request, response) => {
|
|
61
34
|
response.end('undici')
|
|
@@ -66,7 +39,10 @@ await once(server, 'listening')
|
|
|
66
39
|
const client = new Client(`http://localhost:${server.address().port}`)
|
|
67
40
|
|
|
68
41
|
try {
|
|
69
|
-
const { body } = await client.request({
|
|
42
|
+
const { body } = await client.request({
|
|
43
|
+
path: '/',
|
|
44
|
+
method: 'GET'
|
|
45
|
+
})
|
|
70
46
|
body.setEncoding('utf8')
|
|
71
47
|
body.on('data', console.log)
|
|
72
48
|
} catch (error) {}
|
|
@@ -77,41 +53,40 @@ console.log('Client closed')
|
|
|
77
53
|
server.close()
|
|
78
54
|
```
|
|
79
55
|
|
|
80
|
-
### `
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* `
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
import { createServer } from 'node:http'
|
|
56
|
+
### `Dispatcher.connect(options[, callback])`
|
|
57
|
+
|
|
58
|
+
Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
|
|
59
|
+
|
|
60
|
+
Arguments:
|
|
61
|
+
|
|
62
|
+
* **options** `ConnectOptions`
|
|
63
|
+
* **callback** `(err: Error | null, data: ConnectData | null) => void` (optional)
|
|
64
|
+
|
|
65
|
+
Returns: `void | Promise<ConnectData>` - Only returns a `Promise` if no `callback` argument was passed
|
|
66
|
+
|
|
67
|
+
#### Parameter: `ConnectOptions`
|
|
68
|
+
|
|
69
|
+
* **path** `string`
|
|
70
|
+
* **headers** `UndiciHeaders` (optional) - Default: `null`
|
|
71
|
+
* **signal** `AbortSignal | events.EventEmitter | null` (optional) - Default: `null`
|
|
72
|
+
* **opaque** `unknown` (optional) - This argument parameter is passed through to `ConnectData`
|
|
73
|
+
|
|
74
|
+
#### Parameter: `ConnectData`
|
|
75
|
+
|
|
76
|
+
* **statusCode** `number`
|
|
77
|
+
* **headers** `Record<string, string | string[] | undefined>`
|
|
78
|
+
* **socket** `stream.Duplex`
|
|
79
|
+
* **opaque** `unknown`
|
|
80
|
+
|
|
81
|
+
#### Example - Connect request with echo
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { createServer } from 'http'
|
|
110
85
|
import { Client } from 'undici'
|
|
111
|
-
import { once } from '
|
|
86
|
+
import { once } from 'events'
|
|
112
87
|
|
|
113
88
|
const server = createServer((request, response) => {
|
|
114
|
-
throw
|
|
89
|
+
throw Error('should never get here')
|
|
115
90
|
}).listen()
|
|
116
91
|
|
|
117
92
|
server.on('connect', (req, socket, head) => {
|
|
@@ -132,7 +107,9 @@ await once(server, 'listening')
|
|
|
132
107
|
const client = new Client(`http://localhost:${server.address().port}`)
|
|
133
108
|
|
|
134
109
|
try {
|
|
135
|
-
const { socket } = await client.connect({
|
|
110
|
+
const { socket } = await client.connect({
|
|
111
|
+
path: '/'
|
|
112
|
+
})
|
|
136
113
|
const wanted = 'Body'
|
|
137
114
|
let data = ''
|
|
138
115
|
socket.on('data', d => { data += d })
|
|
@@ -143,39 +120,35 @@ try {
|
|
|
143
120
|
})
|
|
144
121
|
socket.write(wanted)
|
|
145
122
|
socket.end()
|
|
146
|
-
} catch (error) {}
|
|
123
|
+
} catch (error) { }
|
|
147
124
|
```
|
|
148
125
|
|
|
149
|
-
### `
|
|
126
|
+
### `Dispatcher.destroy([error, callback]): Promise`
|
|
127
|
+
|
|
128
|
+
Destroy the dispatcher abruptly with the given error. All the pending and running requests will be asynchronously aborted and error. Since this operation is asynchronously dispatched there might still be some progress on dispatched requests.
|
|
150
129
|
|
|
151
|
-
|
|
152
|
-
added: v4.0.0
|
|
153
|
-
-->
|
|
130
|
+
Both arguments are optional; the method can be called in four different ways:
|
|
154
131
|
|
|
155
|
-
|
|
156
|
-
rejected. **Default:** `null`.
|
|
157
|
-
* `callback` {Function} (optional) Invoked once the socket is closed.
|
|
158
|
-
* Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
|
|
159
|
-
resolves with `void` once the dispatcher is destroyed.
|
|
132
|
+
Arguments:
|
|
160
133
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
dispatched asynchronously, dispatched requests may still make some progress
|
|
164
|
-
before being aborted.
|
|
134
|
+
* **error** `Error | null` (optional)
|
|
135
|
+
* **callback** `(error: Error | null, data: null) => void` (optional)
|
|
165
136
|
|
|
166
|
-
|
|
137
|
+
Returns: `void | Promise<void>` - Only returns a `Promise` if no `callback` argument was passed
|
|
167
138
|
|
|
168
|
-
```
|
|
139
|
+
```js
|
|
169
140
|
dispatcher.destroy() // -> Promise
|
|
170
141
|
dispatcher.destroy(new Error()) // -> Promise
|
|
171
142
|
dispatcher.destroy(() => {}) // -> void
|
|
172
143
|
dispatcher.destroy(new Error(), () => {}) // -> void
|
|
173
144
|
```
|
|
174
145
|
|
|
175
|
-
|
|
176
|
-
|
|
146
|
+
#### Example - Request is aborted when Client is destroyed
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
import { createServer } from 'http'
|
|
177
150
|
import { Client } from 'undici'
|
|
178
|
-
import { once } from '
|
|
151
|
+
import { once } from 'events'
|
|
179
152
|
|
|
180
153
|
const server = createServer((request, response) => {
|
|
181
154
|
response.end()
|
|
@@ -186,7 +159,10 @@ await once(server, 'listening')
|
|
|
186
159
|
const client = new Client(`http://localhost:${server.address().port}`)
|
|
187
160
|
|
|
188
161
|
try {
|
|
189
|
-
const request = client.request({
|
|
162
|
+
const request = client.request({
|
|
163
|
+
path: '/',
|
|
164
|
+
method: 'GET'
|
|
165
|
+
})
|
|
190
166
|
client.destroy()
|
|
191
167
|
.then(() => {
|
|
192
168
|
console.log('Client destroyed')
|
|
@@ -198,111 +174,53 @@ try {
|
|
|
198
174
|
}
|
|
199
175
|
```
|
|
200
176
|
|
|
201
|
-
### `
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
* `
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
Required when `options.upgrade` is set or `options.method` is `'CONNECT'`.
|
|
247
|
-
* `controller` {DispatchController}
|
|
248
|
-
* `statusCode` {number}
|
|
249
|
-
* `headers` {Object}
|
|
250
|
-
* `socket` {Duplex}
|
|
251
|
-
* `onResponseStart` {Function} (optional) Invoked when the status code and
|
|
252
|
-
headers have been received. May be invoked multiple times for 1xx
|
|
253
|
-
informational responses. Not used for `upgrade` requests.
|
|
254
|
-
* `controller` {DispatchController}
|
|
255
|
-
* `statusCode` {number}
|
|
256
|
-
* `headers` {Object}
|
|
257
|
-
* `statusMessage` {string} (optional)
|
|
258
|
-
* `onResponseData` {Function} (optional) Invoked when response payload data is
|
|
259
|
-
received. Not used for `upgrade` requests.
|
|
260
|
-
* `controller` {DispatchController}
|
|
261
|
-
* `chunk` {Buffer}
|
|
262
|
-
* `onResponseEnd` {Function} (optional) Invoked when the response payload and
|
|
263
|
-
trailers have been received and the request has completed. Not used for
|
|
264
|
-
`upgrade` requests.
|
|
265
|
-
* `controller` {DispatchController}
|
|
266
|
-
* `trailers` {Object}
|
|
267
|
-
* `onResponseError` {Function} (optional) Invoked when an error occurs. Must not
|
|
268
|
-
throw.
|
|
269
|
-
* `controller` {DispatchController}
|
|
270
|
-
* `error` {Error}
|
|
271
|
-
* `onResponseStarted` {Function} (optional) Invoked when the response is
|
|
272
|
-
received, before headers have been read.
|
|
273
|
-
* `onBodySent` {Function} (optional) Invoked when a chunk of the request body is
|
|
274
|
-
sent. May be invoked multiple times for chunked requests.
|
|
275
|
-
* `chunk` {Buffer}
|
|
276
|
-
* `onRequestSent` {Function} (optional) Invoked after the request body is fully
|
|
277
|
-
sent.
|
|
278
|
-
* Returns: {boolean} `false` when the dispatcher is busy and further `dispatch()`
|
|
279
|
-
calls will make no progress until the [`'drain'`][] event is emitted.
|
|
280
|
-
|
|
281
|
-
This is the low-level API on which all the higher-level methods are built. This
|
|
282
|
-
API is expected to evolve through semver-major versions and is less stable than
|
|
283
|
-
the higher-level methods. It is primarily intended for library developers who
|
|
284
|
-
implement higher-level APIs on top of it.
|
|
285
|
-
|
|
286
|
-
The `controller` passed to each handler is a `DispatchController` with the
|
|
287
|
-
following shape:
|
|
288
|
-
|
|
289
|
-
* `aborted` {boolean} Whether the request has been aborted.
|
|
290
|
-
* `paused` {boolean} Whether the request is paused.
|
|
291
|
-
* `reason` {Error|null} The reason the request was aborted, if any.
|
|
292
|
-
* `rawHeaders` {Buffer[]|string[]|Object|null} The raw response headers,
|
|
293
|
-
preserving duplicates and casing.
|
|
294
|
-
* `rawTrailers` {Buffer[]|string[]|Object|null} The raw response trailers.
|
|
295
|
-
* `abort(reason)` Aborts the request with the given `reason`.
|
|
296
|
-
* `pause()` Pauses the response stream.
|
|
297
|
-
* `resume()` Resumes the response stream.
|
|
298
|
-
|
|
299
|
-
Call `controller.pause()` and `controller.resume()` to apply backpressure rather
|
|
300
|
-
than returning `false` from a handler.
|
|
301
|
-
|
|
302
|
-
```mjs
|
|
303
|
-
import { createServer } from 'node:http'
|
|
177
|
+
### `Dispatcher.dispatch(options, handler)`
|
|
178
|
+
|
|
179
|
+
This is the low level API which all the preceding APIs are implemented on top of.
|
|
180
|
+
This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs.
|
|
181
|
+
It is primarily intended for library developers who implement higher level APIs on top of this.
|
|
182
|
+
|
|
183
|
+
Arguments:
|
|
184
|
+
|
|
185
|
+
* **options** `DispatchOptions`
|
|
186
|
+
* **handler** `DispatchHandler`
|
|
187
|
+
|
|
188
|
+
Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls won't make any progress until the `'drain'` event has been emitted.
|
|
189
|
+
|
|
190
|
+
#### Parameter: `DispatchOptions`
|
|
191
|
+
|
|
192
|
+
* **origin** `string | URL`
|
|
193
|
+
* **path** `string`
|
|
194
|
+
* **method** `string`
|
|
195
|
+
* **reset** `boolean` (optional) - Default: `false` - If `false`, the request will attempt to create a long-living connection by sending the `connection: keep-alive` header,otherwise will attempt to close it immediately after response by sending `connection: close` within the request and closing the socket afterwards.
|
|
196
|
+
* **body** `string | Buffer | Uint8Array | stream.Readable | Iterable | AsyncIterable | null` (optional) - Default: `null`
|
|
197
|
+
* **headers** `UndiciHeaders | string[]` (optional) - Default: `null`.
|
|
198
|
+
* **query** `Record<string, any> | null` (optional) - Default: `null` - Query string params to be embedded in the request URL. Note that both keys and values of query are encoded using `encodeURIComponent`. If for some reason you need to send them unencoded, embed query params into path directly instead.
|
|
199
|
+
* **idempotent** `boolean` (optional) - Default: `true` if `method` is `'HEAD'` or `'GET'` - Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline has completed.
|
|
200
|
+
* **blocking** `boolean` (optional) - Default: `false` - Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received.
|
|
201
|
+
* **upgrade** `string | null` (optional) - Default: `null` - Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`.
|
|
202
|
+
* **bodyTimeout** `number | null` (optional) - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds.
|
|
203
|
+
* **headersTimeout** `number | null` (optional) - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds.
|
|
204
|
+
* **throwOnError** `boolean` (optional) - Default: `false` - Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server.
|
|
205
|
+
* **expectContinue** `boolean` (optional) - Default: `false` - For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server
|
|
206
|
+
|
|
207
|
+
#### Parameter: `DispatchHandler`
|
|
208
|
+
|
|
209
|
+
* **onConnect** `(abort: () => void, context: object) => void` - Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails.
|
|
210
|
+
* **onError** `(error: Error) => void` - Invoked when an error has occurred. May not throw.
|
|
211
|
+
* **onUpgrade** `(statusCode: number, headers: Buffer[], socket: Duplex) => void` (optional) - Invoked when request is upgraded. Required if `DispatchOptions.upgrade` is defined or `DispatchOptions.method === 'CONNECT'`.
|
|
212
|
+
* **onResponseStarted** `() => void` (optional) - Invoked when response is received, before headers have been read.
|
|
213
|
+
* **onHeaders** `(statusCode: number, headers: Buffer[], resume: () => void, statusText: string) => boolean` - Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. Not required for `upgrade` requests.
|
|
214
|
+
* **onData** `(chunk: Buffer) => boolean` - Invoked when response payload data is received. Not required for `upgrade` requests.
|
|
215
|
+
* **onComplete** `(trailers: Buffer[]) => void` - Invoked when response payload and trailers have been received and the request has completed. Not required for `upgrade` requests.
|
|
216
|
+
* **onBodySent** `(chunk: string | Buffer | Uint8Array) => void` - Invoked when a body chunk is sent to the server. Not required. For a stream or iterable body this will be invoked for every chunk. For other body types, it will be invoked once after the body is sent.
|
|
217
|
+
|
|
218
|
+
#### Example 1 - Dispatch GET request
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
import { createServer } from 'http'
|
|
304
222
|
import { Client } from 'undici'
|
|
305
|
-
import { once } from '
|
|
223
|
+
import { once } from 'events'
|
|
306
224
|
|
|
307
225
|
const server = createServer((request, response) => {
|
|
308
226
|
response.end('Hello, World!')
|
|
@@ -317,61 +235,169 @@ const data = []
|
|
|
317
235
|
client.dispatch({
|
|
318
236
|
path: '/',
|
|
319
237
|
method: 'GET',
|
|
320
|
-
headers: {
|
|
238
|
+
headers: {
|
|
239
|
+
'x-foo': 'bar'
|
|
240
|
+
}
|
|
321
241
|
}, {
|
|
322
|
-
|
|
242
|
+
onConnect: () => {
|
|
323
243
|
console.log('Connected!')
|
|
324
244
|
},
|
|
325
|
-
|
|
245
|
+
onError: (error) => {
|
|
326
246
|
console.error(error)
|
|
327
247
|
},
|
|
328
|
-
|
|
329
|
-
console.log(`statusCode: ${statusCode} | headers: ${
|
|
248
|
+
onHeaders: (statusCode, headers) => {
|
|
249
|
+
console.log(`onHeaders | statusCode: ${statusCode} | headers: ${headers}`)
|
|
330
250
|
},
|
|
331
|
-
|
|
251
|
+
onData: (chunk) => {
|
|
252
|
+
console.log('onData: chunk received')
|
|
332
253
|
data.push(chunk)
|
|
333
254
|
},
|
|
334
|
-
|
|
335
|
-
console.log(`trailers: ${
|
|
336
|
-
|
|
255
|
+
onComplete: (trailers) => {
|
|
256
|
+
console.log(`onComplete | trailers: ${trailers}`)
|
|
257
|
+
const res = Buffer.concat(data).toString('utf8')
|
|
258
|
+
console.log(`Data: ${res}`)
|
|
337
259
|
client.close()
|
|
338
260
|
server.close()
|
|
339
261
|
}
|
|
340
262
|
})
|
|
341
263
|
```
|
|
342
264
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
265
|
+
#### Example 2 - Dispatch Upgrade Request
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
import { createServer } from 'http'
|
|
269
|
+
import { Client } from 'undici'
|
|
270
|
+
import { once } from 'events'
|
|
271
|
+
|
|
272
|
+
const server = createServer((request, response) => {
|
|
273
|
+
response.end()
|
|
274
|
+
}).listen()
|
|
275
|
+
|
|
276
|
+
await once(server, 'listening')
|
|
277
|
+
|
|
278
|
+
server.on('upgrade', (request, socket, head) => {
|
|
279
|
+
console.log('Node.js Server - upgrade event')
|
|
280
|
+
socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n')
|
|
281
|
+
socket.write('Upgrade: WebSocket\r\n')
|
|
282
|
+
socket.write('Connection: Upgrade\r\n')
|
|
283
|
+
socket.write('\r\n')
|
|
284
|
+
socket.end()
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
const client = new Client(`http://localhost:${server.address().port}`)
|
|
288
|
+
|
|
289
|
+
client.dispatch({
|
|
290
|
+
path: '/',
|
|
291
|
+
method: 'GET',
|
|
292
|
+
upgrade: 'websocket'
|
|
293
|
+
}, {
|
|
294
|
+
onConnect: () => {
|
|
295
|
+
console.log('Undici Client - onConnect')
|
|
296
|
+
},
|
|
297
|
+
onError: (error) => {
|
|
298
|
+
console.log('onError') // shouldn't print
|
|
299
|
+
},
|
|
300
|
+
onUpgrade: (statusCode, headers, socket) => {
|
|
301
|
+
console.log('Undici Client - onUpgrade')
|
|
302
|
+
console.log(`onUpgrade Headers: ${headers}`)
|
|
303
|
+
socket.on('data', buffer => {
|
|
304
|
+
console.log(buffer.toString('utf8'))
|
|
305
|
+
})
|
|
306
|
+
socket.on('end', () => {
|
|
307
|
+
client.close()
|
|
308
|
+
server.close()
|
|
309
|
+
})
|
|
310
|
+
socket.end()
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### Example 3 - Dispatch POST request
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
import { createServer } from 'http'
|
|
373
319
|
import { Client } from 'undici'
|
|
374
|
-
import { once } from '
|
|
320
|
+
import { once } from 'events'
|
|
321
|
+
|
|
322
|
+
const server = createServer((request, response) => {
|
|
323
|
+
request.on('data', (data) => {
|
|
324
|
+
console.log(`Request Data: ${data.toString('utf8')}`)
|
|
325
|
+
const body = JSON.parse(data)
|
|
326
|
+
body.message = 'World'
|
|
327
|
+
response.end(JSON.stringify(body))
|
|
328
|
+
})
|
|
329
|
+
}).listen()
|
|
330
|
+
|
|
331
|
+
await once(server, 'listening')
|
|
332
|
+
|
|
333
|
+
const client = new Client(`http://localhost:${server.address().port}`)
|
|
334
|
+
|
|
335
|
+
const data = []
|
|
336
|
+
|
|
337
|
+
client.dispatch({
|
|
338
|
+
path: '/',
|
|
339
|
+
method: 'POST',
|
|
340
|
+
headers: {
|
|
341
|
+
'content-type': 'application/json'
|
|
342
|
+
},
|
|
343
|
+
body: JSON.stringify({ message: 'Hello' })
|
|
344
|
+
}, {
|
|
345
|
+
onConnect: () => {
|
|
346
|
+
console.log('Connected!')
|
|
347
|
+
},
|
|
348
|
+
onError: (error) => {
|
|
349
|
+
console.error(error)
|
|
350
|
+
},
|
|
351
|
+
onHeaders: (statusCode, headers) => {
|
|
352
|
+
console.log(`onHeaders | statusCode: ${statusCode} | headers: ${headers}`)
|
|
353
|
+
},
|
|
354
|
+
onData: (chunk) => {
|
|
355
|
+
console.log('onData: chunk received')
|
|
356
|
+
data.push(chunk)
|
|
357
|
+
},
|
|
358
|
+
onComplete: (trailers) => {
|
|
359
|
+
console.log(`onComplete | trailers: ${trailers}`)
|
|
360
|
+
const res = Buffer.concat(data).toString('utf8')
|
|
361
|
+
console.log(`Response Data: ${res}`)
|
|
362
|
+
client.close()
|
|
363
|
+
server.close()
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### `Dispatcher.pipeline(options, handler)`
|
|
369
|
+
|
|
370
|
+
For easy use with [stream.pipeline](https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback). The `handler` argument should return a `Readable` from which the result will be read. Usually it should just return the `body` argument unless some kind of transformation needs to be performed based on e.g. `headers` or `statusCode`. The `handler` should validate the response and save any required state. If there is an error, it should be thrown. The function returns a `Duplex` which writes to the request and reads from the response.
|
|
371
|
+
|
|
372
|
+
Arguments:
|
|
373
|
+
|
|
374
|
+
* **options** `PipelineOptions`
|
|
375
|
+
* **handler** `(data: PipelineHandlerData) => stream.Readable`
|
|
376
|
+
|
|
377
|
+
Returns: `stream.Duplex`
|
|
378
|
+
|
|
379
|
+
#### Parameter: PipelineOptions
|
|
380
|
+
|
|
381
|
+
Extends: [`RequestOptions`](#parameter-requestoptions)
|
|
382
|
+
|
|
383
|
+
* **objectMode** `boolean` (optional) - Default: `false` - Set to `true` if the `handler` will return an object stream.
|
|
384
|
+
|
|
385
|
+
#### Parameter: PipelineHandlerData
|
|
386
|
+
|
|
387
|
+
* **statusCode** `number`
|
|
388
|
+
* **headers** `Record<string, string | string[] | undefined>`
|
|
389
|
+
* **opaque** `unknown`
|
|
390
|
+
* **body** `stream.Readable`
|
|
391
|
+
* **context** `object`
|
|
392
|
+
* **onInfo** `({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
|
|
393
|
+
|
|
394
|
+
#### Example 1 - Pipeline Echo
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
import { Readable, Writable, PassThrough, pipeline } from 'stream'
|
|
398
|
+
import { createServer } from 'http'
|
|
399
|
+
import { Client } from 'undici'
|
|
400
|
+
import { once } from 'events'
|
|
375
401
|
|
|
376
402
|
const server = createServer((request, response) => {
|
|
377
403
|
request.pipe(response)
|
|
@@ -390,7 +416,10 @@ pipeline(
|
|
|
390
416
|
this.push(null)
|
|
391
417
|
}
|
|
392
418
|
}),
|
|
393
|
-
client.pipeline({
|
|
419
|
+
client.pipeline({
|
|
420
|
+
path: '/',
|
|
421
|
+
method: 'GET'
|
|
422
|
+
}, ({ statusCode, headers, body }) => {
|
|
394
423
|
console.log(`response received ${statusCode}`)
|
|
395
424
|
console.log('headers', headers)
|
|
396
425
|
return pipeline(body, new PassThrough(), () => {})
|
|
@@ -409,81 +438,78 @@ pipeline(
|
|
|
409
438
|
if (error) {
|
|
410
439
|
console.error(error)
|
|
411
440
|
}
|
|
441
|
+
|
|
412
442
|
client.close()
|
|
413
443
|
server.close()
|
|
414
444
|
}
|
|
415
445
|
)
|
|
416
446
|
```
|
|
417
447
|
|
|
418
|
-
### `
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
*
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
[`.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
`
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
`json()`.
|
|
482
|
-
|
|
483
|
-
```mjs
|
|
484
|
-
import { createServer } from 'node:http'
|
|
448
|
+
### `Dispatcher.request(options[, callback])`
|
|
449
|
+
|
|
450
|
+
Performs a HTTP request.
|
|
451
|
+
|
|
452
|
+
Non-idempotent requests will not be pipelined in order
|
|
453
|
+
to avoid indirect failures.
|
|
454
|
+
|
|
455
|
+
Idempotent requests will be automatically retried if
|
|
456
|
+
they fail due to indirect failure from the request
|
|
457
|
+
at the head of the pipeline. This does not apply to
|
|
458
|
+
idempotent requests with a stream request body.
|
|
459
|
+
|
|
460
|
+
All response bodies must always be fully consumed or destroyed.
|
|
461
|
+
|
|
462
|
+
Arguments:
|
|
463
|
+
|
|
464
|
+
* **options** `RequestOptions`
|
|
465
|
+
* **callback** `(error: Error | null, data: ResponseData) => void` (optional)
|
|
466
|
+
|
|
467
|
+
Returns: `void | Promise<ResponseData>` - Only returns a `Promise` if no `callback` argument was passed.
|
|
468
|
+
|
|
469
|
+
#### Parameter: `RequestOptions`
|
|
470
|
+
|
|
471
|
+
Extends: [`DispatchOptions`](#parameter-dispatchoptions)
|
|
472
|
+
|
|
473
|
+
* **opaque** `unknown` (optional) - Default: `null` - Used for passing through context to `ResponseData`.
|
|
474
|
+
* **signal** `AbortSignal | events.EventEmitter | null` (optional) - Default: `null`.
|
|
475
|
+
* **onInfo** `({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
|
|
476
|
+
|
|
477
|
+
The `RequestOptions.method` property should not be value `'CONNECT'`.
|
|
478
|
+
|
|
479
|
+
#### Parameter: `ResponseData`
|
|
480
|
+
|
|
481
|
+
* **statusCode** `number`
|
|
482
|
+
* **headers** `Record<string, string | string[]>` - Note that all header keys are lower-cased, e. g. `content-type`.
|
|
483
|
+
* **body** `stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
|
|
484
|
+
* **trailers** `Record<string, string>` - This object starts out
|
|
485
|
+
as empty and will be mutated to contain trailers after `body` has emitted `'end'`.
|
|
486
|
+
* **opaque** `unknown`
|
|
487
|
+
* **context** `object`
|
|
488
|
+
|
|
489
|
+
`body` contains the following additional [body mixin](https://fetch.spec.whatwg.org/#body-mixin) methods and properties:
|
|
490
|
+
|
|
491
|
+
* [`.arrayBuffer()`](https://fetch.spec.whatwg.org/#dom-body-arraybuffer)
|
|
492
|
+
* [`.blob()`](https://fetch.spec.whatwg.org/#dom-body-blob)
|
|
493
|
+
* [`.bytes()`](https://fetch.spec.whatwg.org/#dom-body-bytes)
|
|
494
|
+
* [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
|
|
495
|
+
* [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)
|
|
496
|
+
* `body`
|
|
497
|
+
* `bodyUsed`
|
|
498
|
+
|
|
499
|
+
`body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
500
|
+
|
|
501
|
+
`body` contains the following additional extensions:
|
|
502
|
+
|
|
503
|
+
- `dump({ limit: Integer })`, dump the response by reading up to `limit` bytes without killing the socket (optional) - Default: 262144.
|
|
504
|
+
|
|
505
|
+
Note that body will still be a `Readable` even if it is empty, but attempting to deserialize it with `json()` will result in an exception. Recommended way to ensure there is a body to deserialize is to check if status code is not 204, and `content-type` header starts with `application/json`.
|
|
506
|
+
|
|
507
|
+
#### Example 1 - Basic GET Request
|
|
508
|
+
|
|
509
|
+
```js
|
|
510
|
+
import { createServer } from 'http'
|
|
485
511
|
import { Client } from 'undici'
|
|
486
|
-
import { once } from '
|
|
512
|
+
import { once } from 'events'
|
|
487
513
|
|
|
488
514
|
const server = createServer((request, response) => {
|
|
489
515
|
response.end('Hello, World!')
|
|
@@ -494,7 +520,7 @@ await once(server, 'listening')
|
|
|
494
520
|
const client = new Client(`http://localhost:${server.address().port}`)
|
|
495
521
|
|
|
496
522
|
try {
|
|
497
|
-
const { body, headers, statusCode,
|
|
523
|
+
const { body, headers, statusCode, trailers } = await client.request({
|
|
498
524
|
path: '/',
|
|
499
525
|
method: 'GET'
|
|
500
526
|
})
|
|
@@ -502,7 +528,6 @@ try {
|
|
|
502
528
|
console.log('headers', headers)
|
|
503
529
|
body.setEncoding('utf8')
|
|
504
530
|
body.on('data', console.log)
|
|
505
|
-
body.on('error', console.error)
|
|
506
531
|
body.on('end', () => {
|
|
507
532
|
console.log('trailers', trailers)
|
|
508
533
|
})
|
|
@@ -514,74 +539,132 @@ try {
|
|
|
514
539
|
}
|
|
515
540
|
```
|
|
516
541
|
|
|
517
|
-
|
|
518
|
-
|
|
542
|
+
#### Example 2 - Aborting a request
|
|
543
|
+
|
|
544
|
+
> Node.js v15+ is required to run this example
|
|
519
545
|
|
|
520
|
-
```
|
|
546
|
+
```js
|
|
547
|
+
import { createServer } from 'http'
|
|
521
548
|
import { Client } from 'undici'
|
|
549
|
+
import { once } from 'events'
|
|
522
550
|
|
|
523
|
-
const
|
|
551
|
+
const server = createServer((request, response) => {
|
|
552
|
+
response.end('Hello, World!')
|
|
553
|
+
}).listen()
|
|
554
|
+
|
|
555
|
+
await once(server, 'listening')
|
|
556
|
+
|
|
557
|
+
const client = new Client(`http://localhost:${server.address().port}`)
|
|
524
558
|
const abortController = new AbortController()
|
|
525
559
|
|
|
526
560
|
try {
|
|
527
|
-
client.request({
|
|
561
|
+
client.request({
|
|
562
|
+
path: '/',
|
|
563
|
+
method: 'GET',
|
|
564
|
+
signal: abortController.signal
|
|
565
|
+
})
|
|
528
566
|
} catch (error) {
|
|
529
|
-
console.error(error) // RequestAbortedError
|
|
567
|
+
console.error(error) // should print an RequestAbortedError
|
|
568
|
+
client.close()
|
|
569
|
+
server.close()
|
|
530
570
|
}
|
|
531
571
|
|
|
532
572
|
abortController.abort()
|
|
533
573
|
```
|
|
534
574
|
|
|
535
|
-
|
|
575
|
+
Alternatively, any `EventEmitter` that emits an `'abort'` event may be used as an abort controller:
|
|
576
|
+
|
|
577
|
+
```js
|
|
578
|
+
import { createServer } from 'http'
|
|
579
|
+
import { Client } from 'undici'
|
|
580
|
+
import EventEmitter, { once } from 'events'
|
|
581
|
+
|
|
582
|
+
const server = createServer((request, response) => {
|
|
583
|
+
response.end('Hello, World!')
|
|
584
|
+
}).listen()
|
|
536
585
|
|
|
537
|
-
|
|
538
|
-
const { body, statusCode } = await client.request({ path: '/', method: 'GET' })
|
|
586
|
+
await once(server, 'listening')
|
|
539
587
|
|
|
540
|
-
|
|
541
|
-
|
|
588
|
+
const client = new Client(`http://localhost:${server.address().port}`)
|
|
589
|
+
const ee = new EventEmitter()
|
|
590
|
+
|
|
591
|
+
try {
|
|
592
|
+
client.request({
|
|
593
|
+
path: '/',
|
|
594
|
+
method: 'GET',
|
|
595
|
+
signal: ee
|
|
596
|
+
})
|
|
597
|
+
} catch (error) {
|
|
598
|
+
console.error(error) // should print an RequestAbortedError
|
|
599
|
+
client.close()
|
|
600
|
+
server.close()
|
|
542
601
|
}
|
|
543
602
|
|
|
544
|
-
|
|
603
|
+
ee.emit('abort')
|
|
604
|
+
```
|
|
545
605
|
|
|
546
|
-
|
|
606
|
+
Destroying the request or response body will have the same effect.
|
|
607
|
+
|
|
608
|
+
```js
|
|
609
|
+
import { createServer } from 'http'
|
|
610
|
+
import { Client } from 'undici'
|
|
611
|
+
import { once } from 'events'
|
|
612
|
+
|
|
613
|
+
const server = createServer((request, response) => {
|
|
614
|
+
response.end('Hello, World!')
|
|
615
|
+
}).listen()
|
|
616
|
+
|
|
617
|
+
await once(server, 'listening')
|
|
618
|
+
|
|
619
|
+
const client = new Client(`http://localhost:${server.address().port}`)
|
|
620
|
+
|
|
621
|
+
try {
|
|
622
|
+
const { body } = await client.request({
|
|
623
|
+
path: '/',
|
|
624
|
+
method: 'GET'
|
|
625
|
+
})
|
|
626
|
+
body.destroy()
|
|
627
|
+
} catch (error) {
|
|
628
|
+
console.error(error) // should print an RequestAbortedError
|
|
629
|
+
client.close()
|
|
630
|
+
server.close()
|
|
631
|
+
}
|
|
547
632
|
```
|
|
548
633
|
|
|
549
|
-
### `
|
|
634
|
+
### `Dispatcher.stream(options, factory[, callback])`
|
|
635
|
+
|
|
636
|
+
A faster version of `Dispatcher.request`. This method expects the second argument `factory` to return a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable) stream which the response will be written to. This improves performance by avoiding creating an intermediate [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) stream when the user expects to directly pipe the response body to a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable) stream.
|
|
637
|
+
|
|
638
|
+
As demonstrated in [Example 1 - Basic GET stream request](#example-1---basic-get-stream-request), it is recommended to use the `option.opaque` property to avoid creating a closure for the `factory` method. This pattern works well with Node.js Web Frameworks such as [Fastify](https://fastify.io). See [Example 2 - Stream to Fastify Response](#example-2---stream-to-fastify-response) for more details.
|
|
639
|
+
|
|
640
|
+
Arguments:
|
|
641
|
+
|
|
642
|
+
* **options** `RequestOptions`
|
|
643
|
+
* **factory** `(data: StreamFactoryData) => stream.Writable`
|
|
644
|
+
* **callback** `(error: Error | null, data: StreamData) => void` (optional)
|
|
645
|
+
|
|
646
|
+
Returns: `void | Promise<StreamData>` - Only returns a `Promise` if no `callback` argument was passed
|
|
550
647
|
|
|
551
|
-
|
|
552
|
-
added: v4.0.0
|
|
553
|
-
-->
|
|
648
|
+
#### Parameter: `StreamFactoryData`
|
|
554
649
|
|
|
555
|
-
*
|
|
556
|
-
|
|
557
|
-
*
|
|
558
|
-
|
|
559
|
-
* `statusCode` {number}
|
|
560
|
-
* `headers` {Object} The response headers.
|
|
561
|
-
* `opaque` {any} The `opaque` value passed in `options`.
|
|
562
|
-
* `context` {Object}
|
|
563
|
-
* Returns: {Writable}
|
|
564
|
-
* `callback` {Function} (optional) Invoked when the request has completed.
|
|
565
|
-
* `error` {Error|null}
|
|
566
|
-
* `data` {Object}
|
|
567
|
-
* `opaque` {any} The `opaque` value passed in `options`.
|
|
568
|
-
* `trailers` {Object}
|
|
569
|
-
* Returns: {Promise} A `Promise` is returned only when `callback` is omitted. It
|
|
570
|
-
resolves with the `data` object described above.
|
|
650
|
+
* **statusCode** `number`
|
|
651
|
+
* **headers** `Record<string, string | string[] | undefined>`
|
|
652
|
+
* **opaque** `unknown`
|
|
653
|
+
* **onInfo** `({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
|
|
571
654
|
|
|
572
|
-
|
|
573
|
-
[`Writable`][] to which the response is written, which avoids creating an
|
|
574
|
-
intermediate [`Readable`][] when the caller intends to pipe the response body
|
|
575
|
-
directly to a `Writable`.
|
|
655
|
+
#### Parameter: `StreamData`
|
|
576
656
|
|
|
577
|
-
|
|
578
|
-
|
|
657
|
+
* **opaque** `unknown`
|
|
658
|
+
* **trailers** `Record<string, string>`
|
|
659
|
+
* **context** `object`
|
|
579
660
|
|
|
580
|
-
|
|
581
|
-
|
|
661
|
+
#### Example 1 - Basic GET stream request
|
|
662
|
+
|
|
663
|
+
```js
|
|
664
|
+
import { createServer } from 'http'
|
|
582
665
|
import { Client } from 'undici'
|
|
583
|
-
import { once } from '
|
|
584
|
-
import { Writable } from '
|
|
666
|
+
import { once } from 'events'
|
|
667
|
+
import { Writable } from 'stream'
|
|
585
668
|
|
|
586
669
|
const server = createServer((request, response) => {
|
|
587
670
|
response.end('Hello, World!')
|
|
@@ -618,38 +701,95 @@ try {
|
|
|
618
701
|
}
|
|
619
702
|
```
|
|
620
703
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
704
|
+
#### Example 2 - Stream to Fastify Response
|
|
705
|
+
|
|
706
|
+
In this example, a (fake) request is made to the fastify server using `fastify.inject()`. This request then executes the fastify route handler which makes a subsequent request to the raw Node.js http server using `undici.dispatcher.stream()`. The fastify response is passed to the `opaque` option so that undici can tap into the underlying writable stream using `response.raw`. This methodology demonstrates how one could use undici and fastify together to create fast-as-possible requests from one backend server to another.
|
|
707
|
+
|
|
708
|
+
```js
|
|
709
|
+
import { createServer } from 'http'
|
|
710
|
+
import { Client } from 'undici'
|
|
711
|
+
import { once } from 'events'
|
|
712
|
+
import fastify from 'fastify'
|
|
713
|
+
|
|
714
|
+
const nodeServer = createServer((request, response) => {
|
|
715
|
+
response.end('Hello, World! From Node.js HTTP Server')
|
|
716
|
+
}).listen()
|
|
717
|
+
|
|
718
|
+
await once(nodeServer, 'listening')
|
|
719
|
+
|
|
720
|
+
console.log('Node Server listening')
|
|
721
|
+
|
|
722
|
+
const nodeServerUndiciClient = new Client(`http://localhost:${nodeServer.address().port}`)
|
|
723
|
+
|
|
724
|
+
const fastifyServer = fastify()
|
|
725
|
+
|
|
726
|
+
fastifyServer.route({
|
|
727
|
+
url: '/',
|
|
728
|
+
method: 'GET',
|
|
729
|
+
handler: (request, response) => {
|
|
730
|
+
nodeServerUndiciClient.stream({
|
|
731
|
+
path: '/',
|
|
732
|
+
method: 'GET',
|
|
733
|
+
opaque: response
|
|
734
|
+
}, ({ opaque }) => opaque.raw)
|
|
735
|
+
}
|
|
736
|
+
})
|
|
737
|
+
|
|
738
|
+
await fastifyServer.listen()
|
|
739
|
+
|
|
740
|
+
console.log('Fastify Server listening')
|
|
741
|
+
|
|
742
|
+
const fastifyServerUndiciClient = new Client(`http://localhost:${fastifyServer.server.address().port}`)
|
|
743
|
+
|
|
744
|
+
try {
|
|
745
|
+
const { statusCode, body } = await fastifyServerUndiciClient.request({
|
|
746
|
+
path: '/',
|
|
747
|
+
method: 'GET'
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
console.log(`response received ${statusCode}`)
|
|
751
|
+
body.setEncoding('utf8')
|
|
752
|
+
body.on('data', console.log)
|
|
753
|
+
|
|
754
|
+
nodeServerUndiciClient.close()
|
|
755
|
+
fastifyServerUndiciClient.close()
|
|
756
|
+
fastifyServer.close()
|
|
757
|
+
nodeServer.close()
|
|
758
|
+
} catch (error) { }
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### `Dispatcher.upgrade(options[, callback])`
|
|
762
|
+
|
|
763
|
+
Upgrade to a different protocol. Visit [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
|
|
764
|
+
|
|
765
|
+
Arguments:
|
|
766
|
+
|
|
767
|
+
* **options** `UpgradeOptions`
|
|
768
|
+
|
|
769
|
+
* **callback** `(error: Error | null, data: UpgradeData) => void` (optional)
|
|
770
|
+
|
|
771
|
+
Returns: `void | Promise<UpgradeData>` - Only returns a `Promise` if no `callback` argument was passed
|
|
772
|
+
|
|
773
|
+
#### Parameter: `UpgradeOptions`
|
|
774
|
+
|
|
775
|
+
* **path** `string`
|
|
776
|
+
* **method** `string` (optional) - Default: `'GET'`
|
|
777
|
+
* **headers** `UndiciHeaders` (optional) - Default: `null`
|
|
778
|
+
* **protocol** `string` (optional) - Default: `'Websocket'` - A string of comma separated protocols, in descending preference order.
|
|
779
|
+
* **signal** `AbortSignal | EventEmitter | null` (optional) - Default: `null`
|
|
780
|
+
|
|
781
|
+
#### Parameter: `UpgradeData`
|
|
782
|
+
|
|
783
|
+
* **headers** `http.IncomingHeaders`
|
|
784
|
+
* **socket** `stream.Duplex`
|
|
785
|
+
* **opaque** `unknown`
|
|
786
|
+
|
|
787
|
+
#### Example 1 - Basic Upgrade Request
|
|
788
|
+
|
|
789
|
+
```js
|
|
790
|
+
import { createServer } from 'http'
|
|
651
791
|
import { Client } from 'undici'
|
|
652
|
-
import { once } from '
|
|
792
|
+
import { once } from 'events'
|
|
653
793
|
|
|
654
794
|
const server = createServer((request, response) => {
|
|
655
795
|
response.statusCode = 101
|
|
@@ -663,7 +803,9 @@ await once(server, 'listening')
|
|
|
663
803
|
const client = new Client(`http://localhost:${server.address().port}`)
|
|
664
804
|
|
|
665
805
|
try {
|
|
666
|
-
const { headers, socket } = await client.upgrade({
|
|
806
|
+
const { headers, socket } = await client.upgrade({
|
|
807
|
+
path: '/',
|
|
808
|
+
})
|
|
667
809
|
socket.on('end', () => {
|
|
668
810
|
console.log(`upgrade: ${headers.upgrade}`) // upgrade: Websocket
|
|
669
811
|
client.close()
|
|
@@ -677,62 +819,90 @@ try {
|
|
|
677
819
|
}
|
|
678
820
|
```
|
|
679
821
|
|
|
680
|
-
### `
|
|
822
|
+
### `Dispatcher.compose(interceptors[, interceptor])`
|
|
681
823
|
|
|
682
|
-
|
|
683
|
-
added: v6.9.0
|
|
684
|
-
-->
|
|
824
|
+
Compose a new dispatcher from the current dispatcher and the given interceptors.
|
|
685
825
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
* Returns: {Dispatcher} A new dispatcher that applies the interceptors over the
|
|
691
|
-
current dispatcher's [`dispatch()`][] method.
|
|
826
|
+
> _Notes_:
|
|
827
|
+
> - The order of the interceptors matters. The first interceptor will be the first to be called.
|
|
828
|
+
> - It is important to note that the `interceptor` function should return a function that follows the `Dispatcher.dispatch` signature.
|
|
829
|
+
> - Any fork of the chain of `interceptors` can lead to unexpected results.
|
|
692
830
|
|
|
693
|
-
|
|
694
|
-
interceptors. Each interceptor is a function that takes a `dispatch` method and
|
|
695
|
-
returns a `dispatch`-like function with the same signature
|
|
696
|
-
(`(options, handler)`).
|
|
831
|
+
Arguments:
|
|
697
832
|
|
|
698
|
-
|
|
699
|
-
first to be called. Forking the chain of interceptors can lead to unexpected
|
|
700
|
-
results.
|
|
833
|
+
* **interceptors** `Interceptor[interceptor[]]`: It is an array of `Interceptor` functions passed as only argument, or several interceptors passed as separate arguments.
|
|
701
834
|
|
|
702
|
-
|
|
703
|
-
compose([interceptor1, interceptor2, interceptor3])
|
|
835
|
+
Returns: `Dispatcher`.
|
|
704
836
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
```
|
|
837
|
+
#### Parameter: `Interceptor`
|
|
838
|
+
|
|
839
|
+
A function that takes a `dispatch` method and returns a `dispatch`-like function.
|
|
709
840
|
|
|
710
|
-
|
|
711
|
-
|
|
841
|
+
#### Example 1 - Basic Compose
|
|
842
|
+
|
|
843
|
+
```js
|
|
844
|
+
const { Client, RedirectHandler } = require('undici')
|
|
712
845
|
|
|
713
846
|
const redirectInterceptor = dispatch => {
|
|
714
|
-
|
|
715
|
-
|
|
847
|
+
return (opts, handler) => {
|
|
848
|
+
const { maxRedirections } = opts
|
|
716
849
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
850
|
+
if (!maxRedirections) {
|
|
851
|
+
return dispatch(opts, handler)
|
|
852
|
+
}
|
|
720
853
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
854
|
+
const redirectHandler = new RedirectHandler(
|
|
855
|
+
dispatch,
|
|
856
|
+
maxRedirections,
|
|
857
|
+
opts,
|
|
858
|
+
handler
|
|
859
|
+
)
|
|
860
|
+
opts = { ...opts, maxRedirections: 0 } // Stop sub dispatcher from also redirecting.
|
|
861
|
+
return dispatch(opts, redirectHandler)
|
|
862
|
+
}
|
|
725
863
|
}
|
|
726
864
|
|
|
727
|
-
const client = new Client('http://localhost:3000')
|
|
865
|
+
const client = new Client('http://localhost:3000')
|
|
866
|
+
.compose(redirectInterceptor)
|
|
728
867
|
|
|
729
868
|
await client.request({ path: '/', method: 'GET' })
|
|
730
869
|
```
|
|
731
870
|
|
|
732
|
-
|
|
871
|
+
#### Example 2 - Chained Compose
|
|
733
872
|
|
|
734
|
-
```
|
|
735
|
-
|
|
873
|
+
```js
|
|
874
|
+
const { Client, RedirectHandler, RetryHandler } = require('undici')
|
|
875
|
+
|
|
876
|
+
const redirectInterceptor = dispatch => {
|
|
877
|
+
return (opts, handler) => {
|
|
878
|
+
const { maxRedirections } = opts
|
|
879
|
+
|
|
880
|
+
if (!maxRedirections) {
|
|
881
|
+
return dispatch(opts, handler)
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const redirectHandler = new RedirectHandler(
|
|
885
|
+
dispatch,
|
|
886
|
+
maxRedirections,
|
|
887
|
+
opts,
|
|
888
|
+
handler
|
|
889
|
+
)
|
|
890
|
+
opts = { ...opts, maxRedirections: 0 }
|
|
891
|
+
return dispatch(opts, redirectHandler)
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
const retryInterceptor = dispatch => {
|
|
896
|
+
return function retryInterceptor (opts, handler) {
|
|
897
|
+
return dispatch(
|
|
898
|
+
opts,
|
|
899
|
+
new RetryHandler(opts, {
|
|
900
|
+
handler,
|
|
901
|
+
dispatch
|
|
902
|
+
})
|
|
903
|
+
)
|
|
904
|
+
}
|
|
905
|
+
}
|
|
736
906
|
|
|
737
907
|
const client = new Client('http://localhost:3000')
|
|
738
908
|
.compose(redirectInterceptor)
|
|
@@ -741,96 +911,437 @@ const client = new Client('http://localhost:3000')
|
|
|
741
911
|
await client.request({ path: '/', method: 'GET' })
|
|
742
912
|
```
|
|
743
913
|
|
|
744
|
-
|
|
745
|
-
For an example of a custom interceptor that wraps handler callbacks, see
|
|
746
|
-
[Custom interceptors](Interceptors.md#custom-interceptors).
|
|
914
|
+
#### Pre-built interceptors
|
|
747
915
|
|
|
748
|
-
|
|
916
|
+
##### `redirect`
|
|
917
|
+
|
|
918
|
+
The `redirect` interceptor allows you to customize the way your dispatcher handles redirects.
|
|
919
|
+
|
|
920
|
+
It accepts the same arguments as the [`RedirectHandler` constructor](./RedirectHandler.md).
|
|
921
|
+
|
|
922
|
+
**Example - Basic Redirect Interceptor**
|
|
923
|
+
|
|
924
|
+
```js
|
|
925
|
+
const { Client, interceptors } = require("undici");
|
|
926
|
+
const { redirect } = interceptors;
|
|
927
|
+
|
|
928
|
+
const client = new Client("http://example.com").compose(
|
|
929
|
+
redirect({ maxRedirections: 3, throwOnMaxRedirects: true })
|
|
930
|
+
);
|
|
931
|
+
client.request({ path: "/" })
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
##### `retry`
|
|
935
|
+
|
|
936
|
+
The `retry` interceptor allows you to customize the way your dispatcher handles retries.
|
|
937
|
+
|
|
938
|
+
It accepts the same arguments as the [`RetryHandler` constructor](./RetryHandler.md).
|
|
939
|
+
|
|
940
|
+
**Example - Basic Redirect Interceptor**
|
|
941
|
+
|
|
942
|
+
```js
|
|
943
|
+
const { Client, interceptors } = require("undici");
|
|
944
|
+
const { retry } = interceptors;
|
|
945
|
+
|
|
946
|
+
const client = new Client("http://example.com").compose(
|
|
947
|
+
retry({
|
|
948
|
+
maxRetries: 3,
|
|
949
|
+
minTimeout: 1000,
|
|
950
|
+
maxTimeout: 10000,
|
|
951
|
+
timeoutFactor: 2,
|
|
952
|
+
retryAfter: true,
|
|
953
|
+
})
|
|
954
|
+
);
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
##### `dump`
|
|
958
|
+
|
|
959
|
+
The `dump` interceptor enables you to dump the response body from a request upon a given limit.
|
|
960
|
+
|
|
961
|
+
**Options**
|
|
962
|
+
- `maxSize` - The maximum size (in bytes) of the response body to dump. If the size of the request's body exceeds this value then the connection will be closed. Default: `1048576`.
|
|
963
|
+
|
|
964
|
+
> The `Dispatcher#options` also gets extended with the options `dumpMaxSize`, `abortOnDumped`, and `waitForTrailers` which can be used to configure the interceptor at a request-per-request basis.
|
|
965
|
+
|
|
966
|
+
**Example - Basic Dump Interceptor**
|
|
967
|
+
|
|
968
|
+
```js
|
|
969
|
+
const { Client, interceptors } = require("undici");
|
|
970
|
+
const { dump } = interceptors;
|
|
971
|
+
|
|
972
|
+
const client = new Client("http://example.com").compose(
|
|
973
|
+
dump({
|
|
974
|
+
maxSize: 1024,
|
|
975
|
+
})
|
|
976
|
+
);
|
|
977
|
+
|
|
978
|
+
// or
|
|
979
|
+
client.dispatch(
|
|
980
|
+
{
|
|
981
|
+
path: "/",
|
|
982
|
+
method: "GET",
|
|
983
|
+
dumpMaxSize: 1024,
|
|
984
|
+
},
|
|
985
|
+
handler
|
|
986
|
+
);
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
##### `dns`
|
|
990
|
+
|
|
991
|
+
The `dns` interceptor enables you to cache DNS lookups for a given duration, per origin.
|
|
992
|
+
|
|
993
|
+
>It is well suited for scenarios where you want to cache DNS lookups to avoid the overhead of resolving the same domain multiple times
|
|
994
|
+
|
|
995
|
+
**Options**
|
|
996
|
+
- `maxTTL` - The maximum time-to-live (in milliseconds) of the DNS cache. It should be a positive integer. Default: `10000`.
|
|
997
|
+
- Set `0` to disable TTL.
|
|
998
|
+
- `maxItems` - The maximum number of items to cache. It should be a positive integer. Default: `Infinity`.
|
|
999
|
+
- `dualStack` - Whether to resolve both IPv4 and IPv6 addresses. Default: `true`.
|
|
1000
|
+
- It will also attempt a happy-eyeballs-like approach to connect to the available addresses in case of a connection failure.
|
|
1001
|
+
- `affinity` - Whether to use IPv4 or IPv6 addresses. Default: `4`.
|
|
1002
|
+
- It can be either `'4` or `6`.
|
|
1003
|
+
- It will only take effect if `dualStack` is `false`.
|
|
1004
|
+
- `lookup: (hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: DNSInterceptorRecord[]) => void) => void` - Custom lookup function. Default: `dns.lookup`.
|
|
1005
|
+
- For more info see [dns.lookup](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback).
|
|
1006
|
+
- `pick: (origin: URL, records: DNSInterceptorRecords, affinity: 4 | 6) => DNSInterceptorRecord` - Custom pick function. Default: `RoundRobin`.
|
|
1007
|
+
- The function should return a single record from the records array.
|
|
1008
|
+
- By default a simplified version of Round Robin is used.
|
|
1009
|
+
- The `records` property can be mutated to store the state of the balancing algorithm.
|
|
1010
|
+
|
|
1011
|
+
> The `Dispatcher#options` also gets extended with the options `dns.affinity`, `dns.dualStack`, `dns.lookup` and `dns.pick` which can be used to configure the interceptor at a request-per-request basis.
|
|
749
1012
|
|
|
750
|
-
<!-- YAML
|
|
751
|
-
added: v4.0.0
|
|
752
|
-
-->
|
|
753
1013
|
|
|
754
|
-
|
|
755
|
-
|
|
1014
|
+
**DNSInterceptorRecord**
|
|
1015
|
+
It represents a DNS record.
|
|
1016
|
+
- `family` - (`number`) The IP family of the address. It can be either `4` or `6`.
|
|
1017
|
+
- `address` - (`string`) The IP address.
|
|
756
1018
|
|
|
757
|
-
|
|
1019
|
+
**DNSInterceptorOriginRecords**
|
|
1020
|
+
It represents a map of DNS IP addresses records for a single origin.
|
|
1021
|
+
- `4.ips` - (`DNSInterceptorRecord[] | null`) The IPv4 addresses.
|
|
1022
|
+
- `6.ips` - (`DNSInterceptorRecord[] | null`) The IPv6 addresses.
|
|
1023
|
+
|
|
1024
|
+
**Example - Basic DNS Interceptor**
|
|
1025
|
+
|
|
1026
|
+
```js
|
|
1027
|
+
const { Client, interceptors } = require("undici");
|
|
1028
|
+
const { dns } = interceptors;
|
|
1029
|
+
|
|
1030
|
+
const client = new Agent().compose([
|
|
1031
|
+
dns({ ...opts })
|
|
1032
|
+
])
|
|
1033
|
+
|
|
1034
|
+
const response = await client.request({
|
|
1035
|
+
origin: `http://localhost:3030`,
|
|
1036
|
+
...requestOpts
|
|
1037
|
+
})
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
##### `Response Error Interceptor`
|
|
1041
|
+
|
|
1042
|
+
**Introduction**
|
|
1043
|
+
|
|
1044
|
+
The Response Error Interceptor is designed to handle HTTP response errors efficiently. It intercepts responses and throws detailed errors for responses with status codes indicating failure (4xx, 5xx). This interceptor enhances error handling by providing structured error information, including response headers, data, and status codes.
|
|
1045
|
+
|
|
1046
|
+
**ResponseError Class**
|
|
1047
|
+
|
|
1048
|
+
The `ResponseError` class extends the `UndiciError` class and encapsulates detailed error information. It captures the response status code, headers, and data, providing a structured way to handle errors.
|
|
1049
|
+
|
|
1050
|
+
**Definition**
|
|
1051
|
+
|
|
1052
|
+
```js
|
|
1053
|
+
class ResponseError extends UndiciError {
|
|
1054
|
+
constructor (message, code, { headers, data }) {
|
|
1055
|
+
super(message);
|
|
1056
|
+
this.name = 'ResponseError';
|
|
1057
|
+
this.message = message || 'Response error';
|
|
1058
|
+
this.code = 'UND_ERR_RESPONSE';
|
|
1059
|
+
this.statusCode = code;
|
|
1060
|
+
this.data = data;
|
|
1061
|
+
this.headers = headers;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
**Interceptor Handler**
|
|
1067
|
+
|
|
1068
|
+
The interceptor's handler class extends `DecoratorHandler` and overrides methods to capture response details and handle errors based on the response status code.
|
|
1069
|
+
|
|
1070
|
+
**Methods**
|
|
1071
|
+
|
|
1072
|
+
- **onConnect**: Initializes response properties.
|
|
1073
|
+
- **onHeaders**: Captures headers and status code. Decodes body if content type is `application/json` or `text/plain`.
|
|
1074
|
+
- **onData**: Appends chunks to the body if status code indicates an error.
|
|
1075
|
+
- **onComplete**: Finalizes error handling, constructs a `ResponseError`, and invokes the `onError` method.
|
|
1076
|
+
- **onError**: Propagates errors to the handler.
|
|
1077
|
+
|
|
1078
|
+
**Definition**
|
|
1079
|
+
|
|
1080
|
+
```js
|
|
1081
|
+
class Handler extends DecoratorHandler {
|
|
1082
|
+
// Private properties
|
|
1083
|
+
#handler;
|
|
1084
|
+
#statusCode;
|
|
1085
|
+
#contentType;
|
|
1086
|
+
#decoder;
|
|
1087
|
+
#headers;
|
|
1088
|
+
#body;
|
|
1089
|
+
|
|
1090
|
+
constructor (opts, { handler }) {
|
|
1091
|
+
super(handler);
|
|
1092
|
+
this.#handler = handler;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
onConnect (abort) {
|
|
1096
|
+
this.#statusCode = 0;
|
|
1097
|
+
this.#contentType = null;
|
|
1098
|
+
this.#decoder = null;
|
|
1099
|
+
this.#headers = null;
|
|
1100
|
+
this.#body = '';
|
|
1101
|
+
return this.#handler.onConnect(abort);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
onHeaders (statusCode, rawHeaders, resume, statusMessage, headers = parseHeaders(rawHeaders)) {
|
|
1105
|
+
this.#statusCode = statusCode;
|
|
1106
|
+
this.#headers = headers;
|
|
1107
|
+
this.#contentType = headers['content-type'];
|
|
1108
|
+
|
|
1109
|
+
if (this.#statusCode < 400) {
|
|
1110
|
+
return this.#handler.onHeaders(statusCode, rawHeaders, resume, statusMessage, headers);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
if (this.#contentType === 'application/json' || this.#contentType === 'text/plain') {
|
|
1114
|
+
this.#decoder = new TextDecoder('utf-8');
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
onData (chunk) {
|
|
1119
|
+
if (this.#statusCode < 400) {
|
|
1120
|
+
return this.#handler.onData(chunk);
|
|
1121
|
+
}
|
|
1122
|
+
this.#body += this.#decoder?.decode(chunk, { stream: true }) ?? '';
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
onComplete (rawTrailers) {
|
|
1126
|
+
if (this.#statusCode >= 400) {
|
|
1127
|
+
this.#body += this.#decoder?.decode(undefined, { stream: false }) ?? '';
|
|
1128
|
+
if (this.#contentType === 'application/json') {
|
|
1129
|
+
try {
|
|
1130
|
+
this.#body = JSON.parse(this.#body);
|
|
1131
|
+
} catch {
|
|
1132
|
+
// Do nothing...
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
let err;
|
|
1137
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
1138
|
+
Error.stackTraceLimit = 0;
|
|
1139
|
+
try {
|
|
1140
|
+
err = new ResponseError('Response Error', this.#statusCode, this.#headers, this.#body);
|
|
1141
|
+
} finally {
|
|
1142
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
this.#handler.onError(err);
|
|
1146
|
+
} else {
|
|
1147
|
+
this.#handler.onComplete(rawTrailers);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
onError (err) {
|
|
1152
|
+
this.#handler.onError(err);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
module.exports = (dispatch) => (opts, handler) => opts.throwOnError
|
|
1157
|
+
? dispatch(opts, new Handler(opts, { handler }))
|
|
1158
|
+
: dispatch(opts, handler);
|
|
1159
|
+
```
|
|
1160
|
+
|
|
1161
|
+
**Tests**
|
|
1162
|
+
|
|
1163
|
+
Unit tests ensure the interceptor functions correctly, handling both error and non-error responses appropriately.
|
|
1164
|
+
|
|
1165
|
+
**Example Tests**
|
|
1166
|
+
|
|
1167
|
+
- **No Error if `throwOnError` is False**:
|
|
1168
|
+
|
|
1169
|
+
```js
|
|
1170
|
+
test('should not error if request is not meant to throw error', async (t) => {
|
|
1171
|
+
const opts = { throwOnError: false };
|
|
1172
|
+
const handler = { onError: () => {}, onData: () => {}, onComplete: () => {} };
|
|
1173
|
+
const interceptor = createResponseErrorInterceptor((opts, handler) => handler.onComplete());
|
|
1174
|
+
assert.doesNotThrow(() => interceptor(opts, handler));
|
|
1175
|
+
});
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
- **Error if Status Code is in Specified Error Codes**:
|
|
1179
|
+
|
|
1180
|
+
```js
|
|
1181
|
+
test('should error if request status code is in the specified error codes', async (t) => {
|
|
1182
|
+
const opts = { throwOnError: true, statusCodes: [500] };
|
|
1183
|
+
const response = { statusCode: 500 };
|
|
1184
|
+
let capturedError;
|
|
1185
|
+
const handler = {
|
|
1186
|
+
onError: (err) => { capturedError = err; },
|
|
1187
|
+
onData: () => {},
|
|
1188
|
+
onComplete: () => {}
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
const interceptor = createResponseErrorInterceptor((opts, handler) => {
|
|
1192
|
+
if (opts.throwOnError && opts.statusCodes.includes(response.statusCode)) {
|
|
1193
|
+
handler.onError(new Error('Response Error'));
|
|
1194
|
+
} else {
|
|
1195
|
+
handler.onComplete();
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
interceptor({ ...opts, response }, handler);
|
|
1200
|
+
|
|
1201
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
1202
|
+
|
|
1203
|
+
assert(capturedError, 'Expected error to be captured but it was not.');
|
|
1204
|
+
assert.strictEqual(capturedError.message, 'Response Error');
|
|
1205
|
+
assert.strictEqual(response.statusCode, 500);
|
|
1206
|
+
});
|
|
1207
|
+
```
|
|
1208
|
+
|
|
1209
|
+
- **No Error if Status Code is Not in Specified Error Codes**:
|
|
1210
|
+
|
|
1211
|
+
```js
|
|
1212
|
+
test('should not error if request status code is not in the specified error codes', async (t) => {
|
|
1213
|
+
const opts = { throwOnError: true, statusCodes: [500] };
|
|
1214
|
+
const response = { statusCode: 404 };
|
|
1215
|
+
const handler = {
|
|
1216
|
+
onError: () => {},
|
|
1217
|
+
onData: () => {},
|
|
1218
|
+
onComplete: () => {}
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
const interceptor = createResponseErrorInterceptor((opts, handler) => {
|
|
1222
|
+
if (opts.throwOnError && opts.statusCodes.includes(response.statusCode)) {
|
|
1223
|
+
handler.onError(new Error('Response Error'));
|
|
1224
|
+
} else {
|
|
1225
|
+
handler.onComplete();
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
assert.doesNotThrow(() => interceptor({ ...opts, response }, handler));
|
|
1230
|
+
});
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
**Conclusion**
|
|
1234
|
+
|
|
1235
|
+
The Response Error Interceptor provides a robust mechanism for handling HTTP response errors by capturing detailed error information and propagating it through a structured `ResponseError` class. This enhancement improves error handling and debugging capabilities in applications using the interceptor.
|
|
1236
|
+
|
|
1237
|
+
## Instance Events
|
|
1238
|
+
|
|
1239
|
+
### Event: `'connect'`
|
|
1240
|
+
|
|
1241
|
+
Parameters:
|
|
1242
|
+
|
|
1243
|
+
* **origin** `URL`
|
|
1244
|
+
* **targets** `Array<Dispatcher>`
|
|
758
1245
|
|
|
759
1246
|
### Event: `'disconnect'`
|
|
760
1247
|
|
|
761
|
-
|
|
762
|
-
added: v4.0.0
|
|
763
|
-
-->
|
|
1248
|
+
Parameters:
|
|
764
1249
|
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
1250
|
+
* **origin** `URL`
|
|
1251
|
+
* **targets** `Array<Dispatcher>`
|
|
1252
|
+
* **error** `Error`
|
|
768
1253
|
|
|
769
1254
|
Emitted when the dispatcher has been disconnected from the origin.
|
|
770
1255
|
|
|
771
|
-
For HTTP/2, this event is also emitted when the dispatcher
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
protocol, a request may hang if a frame is received between the `HEADER` and
|
|
775
|
-
`DATA` frames. It is recommended to handle this event and close the dispatcher to
|
|
776
|
-
create a new HTTP/2 session.
|
|
1256
|
+
> **Note**: For HTTP/2, this event is also emitted when the dispatcher has received the [GOAWAY Frame](https://webconcepts.info/concepts/http2-frame-type/0x7) with an Error with the message `HTTP/2: "GOAWAY" frame received` and the code `UND_ERR_INFO`.
|
|
1257
|
+
> Due to nature of the protocol of using binary frames, it is possible that requests gets hanging as a frame can be received between the `HEADER` and `DATA` frames.
|
|
1258
|
+
> It is recommended to handle this event and close the dispatcher to create a new HTTP/2 session.
|
|
777
1259
|
|
|
778
1260
|
### Event: `'connectionError'`
|
|
779
1261
|
|
|
780
|
-
|
|
781
|
-
added: v4.0.0
|
|
782
|
-
-->
|
|
1262
|
+
Parameters:
|
|
783
1263
|
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
1264
|
+
* **origin** `URL`
|
|
1265
|
+
* **targets** `Array<Dispatcher>`
|
|
1266
|
+
* **error** `Error`
|
|
787
1267
|
|
|
788
|
-
Emitted when
|
|
1268
|
+
Emitted when dispatcher fails to connect to
|
|
1269
|
+
origin.
|
|
789
1270
|
|
|
790
1271
|
### Event: `'drain'`
|
|
791
1272
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
[
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
[
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
1273
|
+
Parameters:
|
|
1274
|
+
|
|
1275
|
+
* **origin** `URL`
|
|
1276
|
+
|
|
1277
|
+
Emitted when dispatcher is no longer busy.
|
|
1278
|
+
|
|
1279
|
+
## Parameter: `UndiciHeaders`
|
|
1280
|
+
|
|
1281
|
+
* `Record<string, string | string[] | undefined> | string[] | Iterable<[string, string | string[] | undefined]> | null`
|
|
1282
|
+
|
|
1283
|
+
Header arguments such as `options.headers` in [`Client.dispatch`](Client.md#clientdispatchoptions-handlers) can be specified in three forms:
|
|
1284
|
+
* As an object specified by the `Record<string, string | string[] | undefined>` (`IncomingHttpHeaders`) type.
|
|
1285
|
+
* As an array of strings. An array representation of a header list must have an even length, or an `InvalidArgumentError` will be thrown.
|
|
1286
|
+
* As an iterable that can encompass `Headers`, `Map`, or a custom iterator returning key-value pairs.
|
|
1287
|
+
Keys are lowercase and values are not modified.
|
|
1288
|
+
|
|
1289
|
+
Response headers will derive a `host` from the `url` of the [Client](Client.md#class-client) instance if no `host` header was previously specified.
|
|
1290
|
+
|
|
1291
|
+
### Example 1 - Object
|
|
1292
|
+
|
|
1293
|
+
```js
|
|
1294
|
+
{
|
|
1295
|
+
'content-length': '123',
|
|
1296
|
+
'content-type': 'text/plain',
|
|
1297
|
+
connection: 'keep-alive',
|
|
1298
|
+
host: 'mysite.com',
|
|
1299
|
+
accept: '*/*'
|
|
1300
|
+
}
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
### Example 2 - Array
|
|
1304
|
+
|
|
1305
|
+
```js
|
|
1306
|
+
[
|
|
1307
|
+
'content-length', '123',
|
|
1308
|
+
'content-type', 'text/plain',
|
|
1309
|
+
'connection', 'keep-alive',
|
|
1310
|
+
'host', 'mysite.com',
|
|
1311
|
+
'accept', '*/*'
|
|
1312
|
+
]
|
|
1313
|
+
```
|
|
1314
|
+
|
|
1315
|
+
### Example 3 - Iterable
|
|
1316
|
+
|
|
1317
|
+
```js
|
|
1318
|
+
new Headers({
|
|
1319
|
+
'content-length': '123',
|
|
1320
|
+
'content-type': 'text/plain',
|
|
1321
|
+
connection: 'keep-alive',
|
|
1322
|
+
host: 'mysite.com',
|
|
1323
|
+
accept: '*/*'
|
|
1324
|
+
})
|
|
1325
|
+
```
|
|
1326
|
+
or
|
|
1327
|
+
```js
|
|
1328
|
+
new Map([
|
|
1329
|
+
['content-length', '123'],
|
|
1330
|
+
['content-type', 'text/plain'],
|
|
1331
|
+
['connection', 'keep-alive'],
|
|
1332
|
+
['host', 'mysite.com'],
|
|
1333
|
+
['accept', '*/*']
|
|
1334
|
+
])
|
|
1335
|
+
```
|
|
1336
|
+
or
|
|
1337
|
+
```js
|
|
1338
|
+
{
|
|
1339
|
+
*[Symbol.iterator] () {
|
|
1340
|
+
yield ['content-length', '123']
|
|
1341
|
+
yield ['content-type', 'text/plain']
|
|
1342
|
+
yield ['connection', 'keep-alive']
|
|
1343
|
+
yield ['host', 'mysite.com']
|
|
1344
|
+
yield ['accept', '*/*']
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
```
|