monitor-transfer-dsh 0.0.0-stage → 0.1.2
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/CHANGELOG.md +25 -0
- package/README.md +51 -2
- package/cordis.patch.yml +4 -0
- package/lib/client.js +381 -0
- package/lib/index.js +267 -0
- package/package.json +67 -3
- package/skill/SKILL.md +48 -0
- package/skill/tools/node_modules/.package-lock.json +163 -0
- package/skill/tools/node_modules/pg/LICENSE +21 -0
- package/skill/tools/node_modules/pg/README.md +96 -0
- package/skill/tools/node_modules/pg/esm/index.mjs +20 -0
- package/skill/tools/node_modules/pg/lib/client.js +846 -0
- package/skill/tools/node_modules/pg/lib/connection-parameters.js +184 -0
- package/skill/tools/node_modules/pg/lib/connection.js +250 -0
- package/skill/tools/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
- package/skill/tools/node_modules/pg/lib/crypto/sasl.js +262 -0
- package/skill/tools/node_modules/pg/lib/crypto/utils.js +89 -0
- package/skill/tools/node_modules/pg/lib/defaults.js +94 -0
- package/skill/tools/node_modules/pg/lib/index.js +73 -0
- package/skill/tools/node_modules/pg/lib/native/client.js +428 -0
- package/skill/tools/node_modules/pg/lib/native/index.js +2 -0
- package/skill/tools/node_modules/pg/lib/native/query.js +167 -0
- package/skill/tools/node_modules/pg/lib/query.js +263 -0
- package/skill/tools/node_modules/pg/lib/result.js +109 -0
- package/skill/tools/node_modules/pg/lib/stream.js +83 -0
- package/skill/tools/node_modules/pg/lib/type-overrides.js +35 -0
- package/skill/tools/node_modules/pg/lib/utils.js +225 -0
- package/skill/tools/node_modules/pg/package.json +76 -0
- package/skill/tools/node_modules/pg-cloudflare/LICENSE +21 -0
- package/skill/tools/node_modules/pg-cloudflare/README.md +112 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.d.ts +2 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.js +6 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.js.map +1 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.d.ts +29 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.js +171 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.js.map +1 -0
- package/skill/tools/node_modules/pg-cloudflare/esm/index.mjs +3 -0
- package/skill/tools/node_modules/pg-cloudflare/package.json +39 -0
- package/skill/tools/node_modules/pg-cloudflare/src/empty.ts +3 -0
- package/skill/tools/node_modules/pg-cloudflare/src/index.ts +187 -0
- package/skill/tools/node_modules/pg-cloudflare/src/types.d.ts +25 -0
- package/skill/tools/node_modules/pg-connection-string/LICENSE +21 -0
- package/skill/tools/node_modules/pg-connection-string/README.md +105 -0
- package/skill/tools/node_modules/pg-connection-string/esm/index.mjs +8 -0
- package/skill/tools/node_modules/pg-connection-string/index.d.ts +37 -0
- package/skill/tools/node_modules/pg-connection-string/index.js +237 -0
- package/skill/tools/node_modules/pg-connection-string/package.json +51 -0
- package/skill/tools/node_modules/pg-int8/LICENSE +13 -0
- package/skill/tools/node_modules/pg-int8/README.md +16 -0
- package/skill/tools/node_modules/pg-int8/index.js +100 -0
- package/skill/tools/node_modules/pg-int8/package.json +24 -0
- package/skill/tools/node_modules/pg-pool/LICENSE +21 -0
- package/skill/tools/node_modules/pg-pool/README.md +357 -0
- package/skill/tools/node_modules/pg-pool/esm/index.mjs +5 -0
- package/skill/tools/node_modules/pg-pool/index.js +517 -0
- package/skill/tools/node_modules/pg-pool/package.json +51 -0
- package/skill/tools/node_modules/pg-protocol/LICENSE +21 -0
- package/skill/tools/node_modules/pg-protocol/README.md +3 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.js +23 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.d.ts +14 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js +55 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.d.ts +21 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js +113 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js +538 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.d.ts +5 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.js +15 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.d.ts +161 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.js +160 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js +325 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.d.ts +22 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.js +325 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.d.ts +42 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.js +198 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/esm/index.js +11 -0
- package/skill/tools/node_modules/pg-protocol/package.json +44 -0
- package/skill/tools/node_modules/pg-protocol/src/b.ts +25 -0
- package/skill/tools/node_modules/pg-protocol/src/buffer-reader.ts +58 -0
- package/skill/tools/node_modules/pg-protocol/src/buffer-writer.ts +120 -0
- package/skill/tools/node_modules/pg-protocol/src/inbound-parser.test.ts +585 -0
- package/skill/tools/node_modules/pg-protocol/src/index.ts +11 -0
- package/skill/tools/node_modules/pg-protocol/src/messages.ts +262 -0
- package/skill/tools/node_modules/pg-protocol/src/outbound-serializer.test.ts +356 -0
- package/skill/tools/node_modules/pg-protocol/src/parser.ts +414 -0
- package/skill/tools/node_modules/pg-protocol/src/serializer.ts +286 -0
- package/skill/tools/node_modules/pg-protocol/src/testing/buffer-list.ts +67 -0
- package/skill/tools/node_modules/pg-protocol/src/testing/test-buffers.ts +166 -0
- package/skill/tools/node_modules/pg-types/.travis.yml +7 -0
- package/skill/tools/node_modules/pg-types/Makefile +14 -0
- package/skill/tools/node_modules/pg-types/README.md +75 -0
- package/skill/tools/node_modules/pg-types/index.d.ts +137 -0
- package/skill/tools/node_modules/pg-types/index.js +47 -0
- package/skill/tools/node_modules/pg-types/index.test-d.ts +21 -0
- package/skill/tools/node_modules/pg-types/lib/arrayParser.js +11 -0
- package/skill/tools/node_modules/pg-types/lib/binaryParsers.js +257 -0
- package/skill/tools/node_modules/pg-types/lib/builtins.js +73 -0
- package/skill/tools/node_modules/pg-types/lib/textParsers.js +215 -0
- package/skill/tools/node_modules/pg-types/package.json +42 -0
- package/skill/tools/node_modules/pg-types/test/index.js +24 -0
- package/skill/tools/node_modules/pg-types/test/types.js +597 -0
- package/skill/tools/node_modules/pgpass/README.md +74 -0
- package/skill/tools/node_modules/pgpass/lib/helper.js +233 -0
- package/skill/tools/node_modules/pgpass/lib/index.js +23 -0
- package/skill/tools/node_modules/pgpass/package.json +41 -0
- package/skill/tools/node_modules/postgres-array/index.d.ts +4 -0
- package/skill/tools/node_modules/postgres-array/index.js +97 -0
- package/skill/tools/node_modules/postgres-array/license +21 -0
- package/skill/tools/node_modules/postgres-array/package.json +35 -0
- package/skill/tools/node_modules/postgres-array/readme.md +43 -0
- package/skill/tools/node_modules/postgres-bytea/index.js +33 -0
- package/skill/tools/node_modules/postgres-bytea/license +21 -0
- package/skill/tools/node_modules/postgres-bytea/package.json +34 -0
- package/skill/tools/node_modules/postgres-bytea/readme.md +34 -0
- package/skill/tools/node_modules/postgres-date/index.js +116 -0
- package/skill/tools/node_modules/postgres-date/license +21 -0
- package/skill/tools/node_modules/postgres-date/package.json +33 -0
- package/skill/tools/node_modules/postgres-date/readme.md +49 -0
- package/skill/tools/node_modules/postgres-interval/index.d.ts +20 -0
- package/skill/tools/node_modules/postgres-interval/index.js +125 -0
- package/skill/tools/node_modules/postgres-interval/license +21 -0
- package/skill/tools/node_modules/postgres-interval/package.json +36 -0
- package/skill/tools/node_modules/postgres-interval/readme.md +48 -0
- package/skill/tools/node_modules/split2/LICENSE +13 -0
- package/skill/tools/node_modules/split2/README.md +85 -0
- package/skill/tools/node_modules/split2/bench.js +27 -0
- package/skill/tools/node_modules/split2/index.js +141 -0
- package/skill/tools/node_modules/split2/package.json +39 -0
- package/skill/tools/node_modules/split2/test.js +409 -0
- package/skill/tools/node_modules/undici/LICENSE +21 -0
- package/skill/tools/node_modules/undici/README.md +828 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Agent.md +291 -0
- package/skill/tools/node_modules/undici/docs/docs/api/BalancedPool.md +297 -0
- package/skill/tools/node_modules/undici/docs/docs/api/CacheStorage.md +188 -0
- package/skill/tools/node_modules/undici/docs/docs/api/CacheStore.md +375 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Client.md +538 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ClientStats.md +93 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Connector.md +198 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ContentType.md +97 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Cookies.md +179 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Debug.md +78 -0
- package/skill/tools/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +518 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Dispatcher.md +842 -0
- package/skill/tools/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +171 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Errors.md +624 -0
- package/skill/tools/node_modules/undici/docs/docs/api/EventSource.md +358 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Fetch.md +721 -0
- package/skill/tools/node_modules/undici/docs/docs/api/GlobalInstallation.md +121 -0
- package/skill/tools/node_modules/undici/docs/docs/api/H2CClient.md +386 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Interceptors.md +439 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockAgent.md +622 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistory.md +371 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +206 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockClient.md +199 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockErrors.md +63 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockPool.md +618 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Pool.md +278 -0
- package/skill/tools/node_modules/undici/docs/docs/api/PoolStats.md +141 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ProxyAgent.md +248 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RedirectHandler.md +279 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RetryAgent.md +136 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RetryHandler.md +200 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RoundRobinPool.md +239 -0
- package/skill/tools/node_modules/undici/docs/docs/api/SnapshotAgent.md +361 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +256 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Util.md +82 -0
- package/skill/tools/node_modules/undici/docs/docs/api/WebSocket.md +536 -0
- package/skill/tools/node_modules/undici/docs/docs/api/api-lifecycle.md +159 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/client-certificate.md +66 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/crawling.md +60 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +233 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/mocking-request.md +192 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/proxy.md +129 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +226 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/writing-tests.md +65 -0
- package/skill/tools/node_modules/undici/docs/docs/getting-started.md +281 -0
- package/skill/tools/node_modules/undici/docs/docs/index.md +793 -0
- package/skill/tools/node_modules/undici/docs/docs/site.json +125 -0
- package/skill/tools/node_modules/undici/docs/docs/type-map.json +79 -0
- package/skill/tools/node_modules/undici/index-fetch.js +65 -0
- package/skill/tools/node_modules/undici/index.d.ts +3 -0
- package/skill/tools/node_modules/undici/index.js +236 -0
- package/skill/tools/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/skill/tools/node_modules/undici/lib/api/api-connect.js +112 -0
- package/skill/tools/node_modules/undici/lib/api/api-pipeline.js +265 -0
- package/skill/tools/node_modules/undici/lib/api/api-request.js +244 -0
- package/skill/tools/node_modules/undici/lib/api/api-stream.js +270 -0
- package/skill/tools/node_modules/undici/lib/api/api-upgrade.js +121 -0
- package/skill/tools/node_modules/undici/lib/api/index.js +7 -0
- package/skill/tools/node_modules/undici/lib/api/readable.js +615 -0
- package/skill/tools/node_modules/undici/lib/cache/memory-cache-store.js +314 -0
- package/skill/tools/node_modules/undici/lib/cache/sqlite-cache-store.js +593 -0
- package/skill/tools/node_modules/undici/lib/core/connect.js +198 -0
- package/skill/tools/node_modules/undici/lib/core/constants.js +131 -0
- package/skill/tools/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/skill/tools/node_modules/undici/lib/core/errors.js +534 -0
- package/skill/tools/node_modules/undici/lib/core/request.js +582 -0
- package/skill/tools/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/skill/tools/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/skill/tools/node_modules/undici/lib/core/symbols.js +81 -0
- package/skill/tools/node_modules/undici/lib/core/tree.js +160 -0
- package/skill/tools/node_modules/undici/lib/core/util.js +1035 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/agent.js +181 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/balanced-pool.js +217 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client-h1.js +1846 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client-h2.js +1989 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client.js +749 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher.js +58 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +127 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +190 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/parser-h1.js +1065 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/pool-base.js +347 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/pool.js +229 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/proxy-agent.js +418 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/retry-agent.js +48 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/round-robin-pool.js +169 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +350 -0
- package/skill/tools/node_modules/undici/lib/encoding/index.js +33 -0
- package/skill/tools/node_modules/undici/lib/global.js +82 -0
- package/skill/tools/node_modules/undici/lib/handler/cache-handler.js +1222 -0
- package/skill/tools/node_modules/undici/lib/handler/cache-revalidation-handler.js +134 -0
- package/skill/tools/node_modules/undici/lib/handler/decorator-handler.js +76 -0
- package/skill/tools/node_modules/undici/lib/handler/deduplication-handler.js +540 -0
- package/skill/tools/node_modules/undici/lib/handler/redirect-handler.js +284 -0
- package/skill/tools/node_modules/undici/lib/handler/retry-handler.js +686 -0
- package/skill/tools/node_modules/undici/lib/interceptor/cache.js +771 -0
- package/skill/tools/node_modules/undici/lib/interceptor/decompress.js +574 -0
- package/skill/tools/node_modules/undici/lib/interceptor/deduplicate.js +118 -0
- package/skill/tools/node_modules/undici/lib/interceptor/dns.js +593 -0
- package/skill/tools/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/skill/tools/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/skill/tools/node_modules/undici/lib/interceptor/response-error.js +139 -0
- package/skill/tools/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/skill/tools/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/skill/tools/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/skill/tools/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/skill/tools/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/skill/tools/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/skill/tools/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/skill/tools/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/skill/tools/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/skill/tools/node_modules/undici/lib/milo/simd.js +1002 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-agent.js +255 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-interceptor.js +227 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-utils.js +730 -0
- package/skill/tools/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-recorder.js +624 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-utils.js +159 -0
- package/skill/tools/node_modules/undici/lib/util/cache.js +764 -0
- package/skill/tools/node_modules/undici/lib/util/date.js +670 -0
- package/skill/tools/node_modules/undici/lib/util/runtime-features.js +93 -0
- package/skill/tools/node_modules/undici/lib/util/stats.js +32 -0
- package/skill/tools/node_modules/undici/lib/util/timers.js +425 -0
- package/skill/tools/node_modules/undici/lib/web/cache/cache.js +871 -0
- package/skill/tools/node_modules/undici/lib/web/cache/cachestorage.js +158 -0
- package/skill/tools/node_modules/undici/lib/web/cache/util.js +45 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/index.js +211 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/parse.js +318 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/util.js +371 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource.js +547 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/util.js +60 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/body.js +583 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/formdata-parser.js +594 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/formdata.js +272 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/headers.js +722 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/index.js +2451 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/request.js +1117 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/response.js +638 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/util.js +1530 -0
- package/skill/tools/node_modules/undici/lib/web/infra/index.js +244 -0
- package/skill/tools/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/skill/tools/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/skill/tools/node_modules/undici/lib/web/webidl/index.js +992 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/connection.js +350 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/events.js +348 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/frame.js +127 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/receiver.js +530 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketerror.js +107 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketstream.js +511 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/websocket.js +783 -0
- package/skill/tools/node_modules/undici/package.json +154 -0
- package/skill/tools/node_modules/undici/scripts/strip-comments.js +10 -0
- package/skill/tools/node_modules/undici/types/README.md +6 -0
- package/skill/tools/node_modules/undici/types/agent.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/api.d.ts +43 -0
- package/skill/tools/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/cache-interceptor.d.ts +189 -0
- package/skill/tools/node_modules/undici/types/cache.d.ts +36 -0
- package/skill/tools/node_modules/undici/types/client-stats.d.ts +15 -0
- package/skill/tools/node_modules/undici/types/client.d.ts +190 -0
- package/skill/tools/node_modules/undici/types/connector.d.ts +37 -0
- package/skill/tools/node_modules/undici/types/content-type.d.ts +21 -0
- package/skill/tools/node_modules/undici/types/cookies.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/diagnostics-channel.d.ts +75 -0
- package/skill/tools/node_modules/undici/types/dispatcher.d.ts +253 -0
- package/skill/tools/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/skill/tools/node_modules/undici/types/errors.d.ts +202 -0
- package/skill/tools/node_modules/undici/types/eventsource.d.ts +66 -0
- package/skill/tools/node_modules/undici/types/fetch.d.ts +235 -0
- package/skill/tools/node_modules/undici/types/formdata.d.ts +108 -0
- package/skill/tools/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/skill/tools/node_modules/undici/types/global-origin.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/skill/tools/node_modules/undici/types/handlers.d.ts +16 -0
- package/skill/tools/node_modules/undici/types/header.d.ts +165 -0
- package/skill/tools/node_modules/undici/types/index.d.ts +93 -0
- package/skill/tools/node_modules/undici/types/interceptors.d.ts +87 -0
- package/skill/tools/node_modules/undici/types/mock-agent.d.ts +69 -0
- package/skill/tools/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/skill/tools/node_modules/undici/types/mock-client.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/skill/tools/node_modules/undici/types/mock-interceptor.d.ts +98 -0
- package/skill/tools/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/patch.d.ts +29 -0
- package/skill/tools/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/skill/tools/node_modules/undici/types/pool.d.ts +39 -0
- package/skill/tools/node_modules/undici/types/proxy-agent.d.ts +36 -0
- package/skill/tools/node_modules/undici/types/readable.d.ts +68 -0
- package/skill/tools/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/skill/tools/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/skill/tools/node_modules/undici/types/round-robin-pool.d.ts +39 -0
- package/skill/tools/node_modules/undici/types/snapshot-agent.d.ts +113 -0
- package/skill/tools/node_modules/undici/types/socks5-proxy-agent.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/util.d.ts +18 -0
- package/skill/tools/node_modules/undici/types/utility.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/webidl.d.ts +352 -0
- package/skill/tools/node_modules/undici/types/websocket.d.ts +188 -0
- package/skill/tools/node_modules/xtend/.jshintrc +30 -0
- package/skill/tools/node_modules/xtend/LICENSE +20 -0
- package/skill/tools/node_modules/xtend/README.md +32 -0
- package/skill/tools/node_modules/xtend/immutable.js +19 -0
- package/skill/tools/node_modules/xtend/mutable.js +17 -0
- package/skill/tools/node_modules/xtend/package.json +55 -0
- package/skill/tools/node_modules/xtend/test.js +103 -0
- package/skill/tools/package-lock.json +172 -0
- package/skill/tools/package.json +9 -0
- package/skill/tools/transfer_core.js +414 -0
|
@@ -0,0 +1,1846 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/* global WebAssembly */
|
|
4
|
+
|
|
5
|
+
const assert = require('node:assert')
|
|
6
|
+
const util = require('../core/util.js')
|
|
7
|
+
const { channels } = require('../core/diagnostics.js')
|
|
8
|
+
const timers = require('../util/timers.js')
|
|
9
|
+
const {
|
|
10
|
+
RequestContentLengthMismatchError,
|
|
11
|
+
ResponseContentLengthMismatchError,
|
|
12
|
+
RequestAbortedError,
|
|
13
|
+
InvalidArgumentError,
|
|
14
|
+
HeadersTimeoutError,
|
|
15
|
+
HeadersOverflowError,
|
|
16
|
+
SocketError,
|
|
17
|
+
InformationalError,
|
|
18
|
+
BodyTimeoutError,
|
|
19
|
+
HTTPParserError,
|
|
20
|
+
WebAssemblyNotSupportedError,
|
|
21
|
+
ResponseExceededMaxSizeError
|
|
22
|
+
} = require('../core/errors.js')
|
|
23
|
+
const {
|
|
24
|
+
kUrl,
|
|
25
|
+
kReset,
|
|
26
|
+
kClient,
|
|
27
|
+
kParser,
|
|
28
|
+
kBlocking,
|
|
29
|
+
kRunning,
|
|
30
|
+
kPending,
|
|
31
|
+
kSize,
|
|
32
|
+
kWriting,
|
|
33
|
+
kQueue,
|
|
34
|
+
kNoRef,
|
|
35
|
+
kKeepAliveDefaultTimeout,
|
|
36
|
+
kHostHeader,
|
|
37
|
+
kPendingIdx,
|
|
38
|
+
kRunningIdx,
|
|
39
|
+
kError,
|
|
40
|
+
kPipelining,
|
|
41
|
+
kSocket,
|
|
42
|
+
kKeepAliveTimeoutValue,
|
|
43
|
+
kMaxHeadersSize,
|
|
44
|
+
kKeepAliveMaxTimeout,
|
|
45
|
+
kKeepAliveTimeoutThreshold,
|
|
46
|
+
kHeadersTimeout,
|
|
47
|
+
kBodyTimeout,
|
|
48
|
+
kStrictContentLength,
|
|
49
|
+
kMaxRequests,
|
|
50
|
+
kCounter,
|
|
51
|
+
kMaxResponseSize,
|
|
52
|
+
kOnError,
|
|
53
|
+
kResume,
|
|
54
|
+
kHTTPContext,
|
|
55
|
+
kClosed,
|
|
56
|
+
kUseMilo
|
|
57
|
+
} = require('../core/symbols.js')
|
|
58
|
+
|
|
59
|
+
const constants = require('../llhttp/constants.js')
|
|
60
|
+
// Node.js core bundles only llhttp; experimental Milo remains available in npm builds.
|
|
61
|
+
const { H1Parser, getMiloEnabled } = typeof esbuildDetection === 'undefined'
|
|
62
|
+
? require('./parser-h1.js')
|
|
63
|
+
: {}
|
|
64
|
+
const EMPTY_BUF = Buffer.alloc(0)
|
|
65
|
+
const FastBuffer = Buffer[Symbol.species]
|
|
66
|
+
const removeAllListeners = util.removeAllListeners
|
|
67
|
+
const kIdleSocketValidation = Symbol('kIdleSocketValidation')
|
|
68
|
+
const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
|
|
69
|
+
const kSocketUsed = Symbol('kSocketUsed')
|
|
70
|
+
const kTypeOfService = Symbol('kTypeOfService')
|
|
71
|
+
|
|
72
|
+
let extractBody
|
|
73
|
+
|
|
74
|
+
function lazyllhttp () {
|
|
75
|
+
// Check only when HTTP/1 needs the parser, so other APIs remain usable without WASM.
|
|
76
|
+
if (typeof WebAssembly === 'undefined') {
|
|
77
|
+
throw new WebAssemblyNotSupportedError()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
|
|
81
|
+
|
|
82
|
+
let mod
|
|
83
|
+
|
|
84
|
+
// We disable wasm SIMD on older versions of Node.js on ppc64 that are broken on Power >=9 architectures.
|
|
85
|
+
let useWasmSIMD = true
|
|
86
|
+
if (process.arch === 'riscv64') {
|
|
87
|
+
useWasmSIMD = false
|
|
88
|
+
} else if (process.arch === 'ppc64') {
|
|
89
|
+
const [major, minor] = process.versions.node.split('.').map(n => parseInt(n, 10))
|
|
90
|
+
if (major < 24 || (major === 24 && minor < 12)) {
|
|
91
|
+
useWasmSIMD = false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior
|
|
95
|
+
if (process.env.UNDICI_NO_WASM_SIMD === '1') {
|
|
96
|
+
useWasmSIMD = false
|
|
97
|
+
} else if (process.env.UNDICI_NO_WASM_SIMD === '0') {
|
|
98
|
+
useWasmSIMD = true
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (useWasmSIMD) {
|
|
102
|
+
try {
|
|
103
|
+
mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js'))
|
|
104
|
+
} catch {}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!mod) {
|
|
108
|
+
// We could check if the error was caused by the simd option not
|
|
109
|
+
// being enabled, but the occurring of this other error
|
|
110
|
+
// * https://github.com/emscripten-core/emscripten/issues/11495
|
|
111
|
+
// got me to remove that check to avoid breaking Node 12.
|
|
112
|
+
mod = new WebAssembly.Module(llhttpWasmData || require('../llhttp/llhttp-wasm.js'))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return new WebAssembly.Instance(mod, {
|
|
116
|
+
env: {
|
|
117
|
+
/**
|
|
118
|
+
* @param {number} p
|
|
119
|
+
* @param {number} at
|
|
120
|
+
* @param {number} len
|
|
121
|
+
* @returns {number}
|
|
122
|
+
*/
|
|
123
|
+
wasm_on_url: (p, at, len) => {
|
|
124
|
+
return 0
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* @param {number} p
|
|
128
|
+
* @param {number} at
|
|
129
|
+
* @param {number} len
|
|
130
|
+
* @returns {number}
|
|
131
|
+
*/
|
|
132
|
+
wasm_on_status: (p, at, len) => {
|
|
133
|
+
assert(currentParser.ptr === p)
|
|
134
|
+
const start = at - currentBufferPtr + currentBufferRef.byteOffset
|
|
135
|
+
return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len))
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* @param {number} p
|
|
139
|
+
* @returns {number}
|
|
140
|
+
*/
|
|
141
|
+
wasm_on_message_begin: p => {
|
|
142
|
+
assert(currentParser.ptr === p)
|
|
143
|
+
return currentParser.onMessageBegin()
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* @param {number} p
|
|
147
|
+
* @param {number} at
|
|
148
|
+
* @param {number} len
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
wasm_on_header_field: (p, at, len) => {
|
|
152
|
+
assert(currentParser.ptr === p)
|
|
153
|
+
const start = at - currentBufferPtr + currentBufferRef.byteOffset
|
|
154
|
+
return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len))
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* @param {number} p
|
|
158
|
+
* @param {number} at
|
|
159
|
+
* @param {number} len
|
|
160
|
+
* @returns {number}
|
|
161
|
+
*/
|
|
162
|
+
wasm_on_header_value: (p, at, len) => {
|
|
163
|
+
assert(currentParser.ptr === p)
|
|
164
|
+
const start = at - currentBufferPtr + currentBufferRef.byteOffset
|
|
165
|
+
return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len))
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* @param {number} p
|
|
169
|
+
* @param {number} statusCode
|
|
170
|
+
* @param {0|1} upgrade
|
|
171
|
+
* @param {0|1} shouldKeepAlive
|
|
172
|
+
* @returns {number}
|
|
173
|
+
*/
|
|
174
|
+
wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => {
|
|
175
|
+
assert(currentParser.ptr === p)
|
|
176
|
+
return currentParser.onHeadersComplete(statusCode, upgrade === 1, shouldKeepAlive === 1)
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* @param {number} p
|
|
180
|
+
* @param {number} at
|
|
181
|
+
* @param {number} len
|
|
182
|
+
* @returns {number}
|
|
183
|
+
*/
|
|
184
|
+
wasm_on_body: (p, at, len) => {
|
|
185
|
+
assert(currentParser.ptr === p)
|
|
186
|
+
const start = at - currentBufferPtr + currentBufferRef.byteOffset
|
|
187
|
+
return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len))
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* @param {number} p
|
|
191
|
+
* @returns {number}
|
|
192
|
+
*/
|
|
193
|
+
wasm_on_message_complete: p => {
|
|
194
|
+
assert(currentParser.ptr === p)
|
|
195
|
+
return currentParser.onMessageComplete()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let llhttpInstance = null
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @type {Parser|null}
|
|
205
|
+
*/
|
|
206
|
+
let currentParser = null
|
|
207
|
+
let currentBufferRef = null
|
|
208
|
+
/**
|
|
209
|
+
* @type {number}
|
|
210
|
+
*/
|
|
211
|
+
let currentBufferSize = 0
|
|
212
|
+
let currentBufferPtr = null
|
|
213
|
+
let currentBuffer = null
|
|
214
|
+
|
|
215
|
+
const USE_NATIVE_TIMER = 0
|
|
216
|
+
const USE_FAST_TIMER = 1
|
|
217
|
+
|
|
218
|
+
// Use fast timers for headers and body to take eventual event loop
|
|
219
|
+
// latency into account.
|
|
220
|
+
const TIMEOUT_HEADERS = 2 | USE_FAST_TIMER
|
|
221
|
+
const TIMEOUT_BODY = 4 | USE_FAST_TIMER
|
|
222
|
+
|
|
223
|
+
// Use native timers to ignore event loop latency for keep-alive
|
|
224
|
+
// handling.
|
|
225
|
+
const TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER
|
|
226
|
+
|
|
227
|
+
class Parser {
|
|
228
|
+
/**
|
|
229
|
+
* @param {import('./client.js')} client
|
|
230
|
+
* @param {import('net').Socket} socket
|
|
231
|
+
* @param {*} llhttp
|
|
232
|
+
*/
|
|
233
|
+
constructor (client, socket, { exports }) {
|
|
234
|
+
this.llhttp = exports
|
|
235
|
+
this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE)
|
|
236
|
+
this.client = client
|
|
237
|
+
/**
|
|
238
|
+
* @type {import('net').Socket}
|
|
239
|
+
*/
|
|
240
|
+
this.socket = socket
|
|
241
|
+
this.timeout = null
|
|
242
|
+
this.timeoutWeakRef = new WeakRef(this)
|
|
243
|
+
this.timeoutValue = null
|
|
244
|
+
this.timeoutType = null
|
|
245
|
+
this.statusCode = 0
|
|
246
|
+
this.statusText = ''
|
|
247
|
+
this.upgrade = false
|
|
248
|
+
this.headers = []
|
|
249
|
+
this.headersSize = 0
|
|
250
|
+
this.headersMaxSize = client[kMaxHeadersSize]
|
|
251
|
+
this.shouldKeepAlive = false
|
|
252
|
+
this.paused = false
|
|
253
|
+
this.resume = this.resume.bind(this)
|
|
254
|
+
|
|
255
|
+
this.bytesRead = 0
|
|
256
|
+
|
|
257
|
+
this.keepAlive = ''
|
|
258
|
+
this.contentLength = -1
|
|
259
|
+
this.hasTransferEncoding = false
|
|
260
|
+
this.connection = ''
|
|
261
|
+
this.maxResponseSize = client[kMaxResponseSize]
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
setTimeout (delay, type) {
|
|
265
|
+
// If the existing timer and the new timer are of different timer type
|
|
266
|
+
// (fast or native) or have different delay, we need to clear the existing
|
|
267
|
+
// timer and set a new one.
|
|
268
|
+
if (delay !== this.timeoutValue || (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)) {
|
|
269
|
+
// If a timeout is already set, clear it with clearTimeout of the fast
|
|
270
|
+
// timer implementation, as it can clear fast and native timers.
|
|
271
|
+
if (this.timeout) {
|
|
272
|
+
timers.clearTimeout(this.timeout)
|
|
273
|
+
this.timeout = null
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (delay) {
|
|
277
|
+
if (type & USE_FAST_TIMER) {
|
|
278
|
+
this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef)
|
|
279
|
+
} else {
|
|
280
|
+
this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef)
|
|
281
|
+
this.timeout?.unref()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.timeoutValue = delay
|
|
286
|
+
} else if (this.timeout) {
|
|
287
|
+
if (this.timeout.refresh) {
|
|
288
|
+
this.timeout.refresh()
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
this.timeoutType = type
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
resume () {
|
|
296
|
+
if (this.socket.destroyed || !this.paused) {
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
assert(this.ptr != null)
|
|
301
|
+
assert(currentParser === null)
|
|
302
|
+
|
|
303
|
+
this.llhttp.llhttp_resume(this.ptr)
|
|
304
|
+
|
|
305
|
+
assert(this.timeoutType === TIMEOUT_BODY)
|
|
306
|
+
if (this.timeout) {
|
|
307
|
+
if (this.timeout.refresh) {
|
|
308
|
+
this.timeout.refresh()
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
this.paused = false
|
|
313
|
+
this.execute(this.socket.read() || EMPTY_BUF) // Flush parser.
|
|
314
|
+
this.readMore()
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
readMore () {
|
|
318
|
+
while (!this.paused && this.ptr) {
|
|
319
|
+
const chunk = this.socket.read()
|
|
320
|
+
if (chunk === null) {
|
|
321
|
+
break
|
|
322
|
+
}
|
|
323
|
+
this.execute(chunk)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @param {Buffer} chunk
|
|
329
|
+
*/
|
|
330
|
+
execute (chunk) {
|
|
331
|
+
assert(currentParser === null)
|
|
332
|
+
assert(this.ptr != null)
|
|
333
|
+
assert(!this.paused)
|
|
334
|
+
|
|
335
|
+
const { socket, llhttp } = this
|
|
336
|
+
|
|
337
|
+
// Allocate a new buffer if the current buffer is too small.
|
|
338
|
+
if (chunk.length > currentBufferSize) {
|
|
339
|
+
if (currentBufferPtr) {
|
|
340
|
+
llhttp.free(currentBufferPtr)
|
|
341
|
+
}
|
|
342
|
+
// Allocate a buffer that is a multiple of 4096 bytes.
|
|
343
|
+
currentBufferSize = Math.ceil(chunk.length / 4096) * 4096
|
|
344
|
+
currentBufferPtr = llhttp.malloc(currentBufferSize)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (
|
|
348
|
+
currentBuffer === null ||
|
|
349
|
+
currentBuffer.buffer !== llhttp.memory.buffer ||
|
|
350
|
+
currentBuffer.byteOffset !== currentBufferPtr ||
|
|
351
|
+
currentBuffer.byteLength !== currentBufferSize
|
|
352
|
+
) {
|
|
353
|
+
currentBuffer = new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
currentBuffer.set(chunk)
|
|
357
|
+
|
|
358
|
+
// Call `execute` on the wasm parser.
|
|
359
|
+
// We pass the `llhttp_parser` pointer address, the pointer address of buffer view data,
|
|
360
|
+
// and finally the length of bytes to parse.
|
|
361
|
+
// The return value is an error code or `constants.ERROR.OK`.
|
|
362
|
+
try {
|
|
363
|
+
let ret
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
currentBufferRef = chunk
|
|
367
|
+
currentParser = this
|
|
368
|
+
ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, chunk.length)
|
|
369
|
+
} finally {
|
|
370
|
+
currentParser = null
|
|
371
|
+
currentBufferRef = null
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (ret !== constants.ERROR.OK) {
|
|
375
|
+
const data = chunk.subarray(llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr)
|
|
376
|
+
|
|
377
|
+
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
|
378
|
+
this.onUpgrade(data)
|
|
379
|
+
} else if (ret === constants.ERROR.PAUSED) {
|
|
380
|
+
this.paused = true
|
|
381
|
+
socket.unshift(data)
|
|
382
|
+
} else {
|
|
383
|
+
throw this.createError(ret, data)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
} catch (err) {
|
|
387
|
+
util.destroy(socket, err)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
finish () {
|
|
392
|
+
assert(currentParser === null)
|
|
393
|
+
assert(this.ptr != null)
|
|
394
|
+
|
|
395
|
+
const { llhttp } = this
|
|
396
|
+
|
|
397
|
+
// The peer closed the connection. If the body parser was paused by
|
|
398
|
+
// backpressure we must finish parsing before signalling EOF, otherwise
|
|
399
|
+
// llhttp_finish() would crash (it used to assert !paused) or report a
|
|
400
|
+
// half-parsed message. Backpressure is advisory here: onData keeps buffering
|
|
401
|
+
// delivered bytes into the response stream, so resume across pauses and
|
|
402
|
+
// drain whatever is still buffered on the socket. A Content-Length/chunked
|
|
403
|
+
// body reaches on_message_complete during execute(); an EOF-delimited body
|
|
404
|
+
// stays paused (its length is unknown) and is completed by llhttp_finish().
|
|
405
|
+
if (this.paused) {
|
|
406
|
+
let data
|
|
407
|
+
do {
|
|
408
|
+
llhttp.llhttp_resume(this.ptr)
|
|
409
|
+
this.paused = false
|
|
410
|
+
data = this.socket.read() || EMPTY_BUF
|
|
411
|
+
this.execute(data)
|
|
412
|
+
} while (this.paused && data.length > 0)
|
|
413
|
+
|
|
414
|
+
if (this.paused) {
|
|
415
|
+
llhttp.llhttp_resume(this.ptr)
|
|
416
|
+
this.paused = false
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
let ret
|
|
421
|
+
|
|
422
|
+
try {
|
|
423
|
+
currentParser = this
|
|
424
|
+
ret = llhttp.llhttp_finish(this.ptr)
|
|
425
|
+
} finally {
|
|
426
|
+
currentParser = null
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (ret === constants.ERROR.OK) {
|
|
430
|
+
return null
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
|
|
434
|
+
this.paused = true
|
|
435
|
+
return null
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return this.createError(ret, EMPTY_BUF)
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
createError (ret, data) {
|
|
442
|
+
const { llhttp, contentLength, bytesRead } = this
|
|
443
|
+
|
|
444
|
+
if (contentLength !== -1 && bytesRead !== contentLength) {
|
|
445
|
+
return new ResponseContentLengthMismatchError()
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
|
449
|
+
let message = ''
|
|
450
|
+
if (ptr) {
|
|
451
|
+
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|
452
|
+
message =
|
|
453
|
+
'Response does not match the HTTP/1.1 protocol (' + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ')'
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return new HTTPParserError(message, constants.ERROR[ret], data)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
destroy () {
|
|
460
|
+
assert(currentParser === null)
|
|
461
|
+
assert(this.ptr != null)
|
|
462
|
+
|
|
463
|
+
this.llhttp.llhttp_free(this.ptr)
|
|
464
|
+
this.ptr = null
|
|
465
|
+
|
|
466
|
+
this.timeout && timers.clearTimeout(this.timeout)
|
|
467
|
+
this.timeout = null
|
|
468
|
+
this.timeoutValue = null
|
|
469
|
+
this.timeoutType = null
|
|
470
|
+
|
|
471
|
+
this.paused = false
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @param {Buffer} buf
|
|
476
|
+
* @returns {0}
|
|
477
|
+
*/
|
|
478
|
+
onStatus (buf) {
|
|
479
|
+
this.statusText = buf.toString()
|
|
480
|
+
return 0
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @returns {0|-1}
|
|
485
|
+
*/
|
|
486
|
+
onMessageBegin () {
|
|
487
|
+
const { socket, client } = this
|
|
488
|
+
|
|
489
|
+
if (socket.destroyed) {
|
|
490
|
+
return -1
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (client[kRunning] === 0) {
|
|
494
|
+
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
|
495
|
+
return -1
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
499
|
+
if (!request) {
|
|
500
|
+
return -1
|
|
501
|
+
}
|
|
502
|
+
request.onResponseStarted()
|
|
503
|
+
|
|
504
|
+
return 0
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @param {Buffer} buf
|
|
509
|
+
* @returns {number}
|
|
510
|
+
*/
|
|
511
|
+
onHeaderField (buf) {
|
|
512
|
+
const len = this.headers.length
|
|
513
|
+
|
|
514
|
+
if ((len & 1) === 0) {
|
|
515
|
+
this.headers.push(buf)
|
|
516
|
+
} else {
|
|
517
|
+
this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
this.trackHeader(buf.length)
|
|
521
|
+
|
|
522
|
+
return 0
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* @param {Buffer} buf
|
|
527
|
+
* @returns {number}
|
|
528
|
+
*/
|
|
529
|
+
onHeaderValue (buf) {
|
|
530
|
+
let len = this.headers.length
|
|
531
|
+
const isContinuation = (len & 1) === 0
|
|
532
|
+
|
|
533
|
+
if ((len & 1) === 1) {
|
|
534
|
+
this.headers.push(buf)
|
|
535
|
+
len += 1
|
|
536
|
+
} else {
|
|
537
|
+
this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const key = this.headers[len - 2]
|
|
541
|
+
if (key.length === 10) {
|
|
542
|
+
const headerName = util.bufferToLowerCasedHeaderName(key)
|
|
543
|
+
if (headerName === 'keep-alive') {
|
|
544
|
+
this.keepAlive += (isContinuation || this.keepAlive.length === 0 ? '' : ',') + buf.toString()
|
|
545
|
+
} else if (headerName === 'connection') {
|
|
546
|
+
this.connection += (isContinuation || this.connection.length === 0 ? '' : ',') + buf.toString()
|
|
547
|
+
}
|
|
548
|
+
} else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === 'content-length') {
|
|
549
|
+
if (this.contentLength === -1) {
|
|
550
|
+
this.contentLength = 0
|
|
551
|
+
}
|
|
552
|
+
for (let i = 0; i < buf.length; i++) {
|
|
553
|
+
this.contentLength = this.contentLength * 10 + (buf[i] - 0x30)
|
|
554
|
+
}
|
|
555
|
+
} else if (key.length === 17 && util.bufferToLowerCasedHeaderName(key) === 'transfer-encoding') {
|
|
556
|
+
this.hasTransferEncoding = true
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
this.trackHeader(buf.length)
|
|
560
|
+
|
|
561
|
+
return 0
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* @param {number} len
|
|
566
|
+
*/
|
|
567
|
+
trackHeader (len) {
|
|
568
|
+
this.headersSize += len
|
|
569
|
+
if (this.headersSize >= this.headersMaxSize) {
|
|
570
|
+
util.destroy(this.socket, new HeadersOverflowError())
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* @param {Buffer} head
|
|
576
|
+
*/
|
|
577
|
+
onUpgrade (head) {
|
|
578
|
+
const { upgrade, client, socket, headers, statusCode, statusText } = this
|
|
579
|
+
|
|
580
|
+
assert(upgrade)
|
|
581
|
+
assert(client[kSocket] === socket)
|
|
582
|
+
assert(!socket.destroyed)
|
|
583
|
+
assert(!this.paused)
|
|
584
|
+
assert((headers.length & 1) === 0)
|
|
585
|
+
|
|
586
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
587
|
+
assert(request)
|
|
588
|
+
assert(request.upgrade || request.method === 'CONNECT')
|
|
589
|
+
|
|
590
|
+
this.statusCode = 0
|
|
591
|
+
this.statusText = ''
|
|
592
|
+
this.shouldKeepAlive = false
|
|
593
|
+
|
|
594
|
+
this.headers = []
|
|
595
|
+
this.headersSize = 0
|
|
596
|
+
|
|
597
|
+
socket.unshift(head)
|
|
598
|
+
|
|
599
|
+
socket[kParser].destroy()
|
|
600
|
+
socket[kParser] = null
|
|
601
|
+
|
|
602
|
+
socket[kClient] = null
|
|
603
|
+
socket[kError] = null
|
|
604
|
+
|
|
605
|
+
removeAllListeners(socket)
|
|
606
|
+
|
|
607
|
+
client[kSocket] = null
|
|
608
|
+
client[kHTTPContext] = null // TODO (fix): This is hacky...
|
|
609
|
+
client[kQueue][client[kRunningIdx]++] = null
|
|
610
|
+
client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
|
|
611
|
+
|
|
612
|
+
try {
|
|
613
|
+
request.onRequestUpgrade(statusCode, headers, socket, statusText)
|
|
614
|
+
} catch (err) {
|
|
615
|
+
util.errorRequest(client, request, err)
|
|
616
|
+
util.destroy(socket, err)
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
client[kResume]()
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @param {number} statusCode
|
|
624
|
+
* @param {boolean} upgrade
|
|
625
|
+
* @param {boolean} shouldKeepAlive
|
|
626
|
+
* @returns {number}
|
|
627
|
+
*/
|
|
628
|
+
onHeadersComplete (statusCode, upgrade, shouldKeepAlive) {
|
|
629
|
+
const { client, socket, headers, statusText } = this
|
|
630
|
+
|
|
631
|
+
if (socket.destroyed) {
|
|
632
|
+
return -1
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (client[kRunning] === 0) {
|
|
636
|
+
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
|
637
|
+
return -1
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
641
|
+
|
|
642
|
+
if (!request) {
|
|
643
|
+
return -1
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
assert(!this.upgrade)
|
|
647
|
+
assert(this.statusCode < 200)
|
|
648
|
+
|
|
649
|
+
if (statusCode === 100) {
|
|
650
|
+
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
|
651
|
+
return -1
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/* this can only happen if server is misbehaving */
|
|
655
|
+
if (upgrade && !request.upgrade) {
|
|
656
|
+
util.destroy(socket, new SocketError('bad upgrade', util.getSocketInfo(socket)))
|
|
657
|
+
return -1
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
assert(this.timeoutType === TIMEOUT_HEADERS)
|
|
661
|
+
|
|
662
|
+
this.statusCode = statusCode
|
|
663
|
+
this.shouldKeepAlive =
|
|
664
|
+
shouldKeepAlive ||
|
|
665
|
+
// Override llhttp value which does not allow keepAlive for HEAD.
|
|
666
|
+
(request.method === 'HEAD' && !socket[kReset] &&
|
|
667
|
+
/(?:^|,)[\t ]*keep-alive[\t ]*(?:,|$)/i.test(this.connection) &&
|
|
668
|
+
!/(?:^|,)[\t ]*close[\t ]*(?:,|$)/i.test(this.connection))
|
|
669
|
+
|
|
670
|
+
// Responses to HEAD and 204/304 responses never carry content
|
|
671
|
+
if (request.method === 'HEAD' || statusCode === 204 || statusCode === 304) {
|
|
672
|
+
// A non-zero Content-Length or Transfer-Encoding on a 204/304 means the
|
|
673
|
+
// server may also have sent content inappropriately, which would then be
|
|
674
|
+
// parsed as the next response on this connection. Accept it, but do not
|
|
675
|
+
// reuse the connection. HEAD requests are fine tho.
|
|
676
|
+
if (request.method !== 'HEAD' && (this.contentLength > 0 || this.hasTransferEncoding)) {
|
|
677
|
+
this.shouldKeepAlive = false
|
|
678
|
+
}
|
|
679
|
+
this.contentLength = -1
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (this.statusCode >= 200) {
|
|
683
|
+
const bodyTimeout = request.bodyTimeout != null ? request.bodyTimeout : client[kBodyTimeout]
|
|
684
|
+
this.setTimeout(bodyTimeout, TIMEOUT_BODY)
|
|
685
|
+
} else if (this.timeout) {
|
|
686
|
+
if (this.timeout.refresh) {
|
|
687
|
+
this.timeout.refresh()
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (request.method === 'CONNECT') {
|
|
692
|
+
assert(client[kRunning] === 1)
|
|
693
|
+
this.upgrade = true
|
|
694
|
+
return 2
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (upgrade) {
|
|
698
|
+
assert(client[kRunning] === 1)
|
|
699
|
+
this.upgrade = true
|
|
700
|
+
return 2
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
assert((this.headers.length & 1) === 0)
|
|
704
|
+
this.headers = []
|
|
705
|
+
this.headersSize = 0
|
|
706
|
+
|
|
707
|
+
if (this.shouldKeepAlive && client[kPipelining]) {
|
|
708
|
+
const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null
|
|
709
|
+
|
|
710
|
+
if (keepAliveTimeout != null) {
|
|
711
|
+
const timeout = Math.min(keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout])
|
|
712
|
+
if (timeout <= 0) {
|
|
713
|
+
socket[kReset] = true
|
|
714
|
+
} else {
|
|
715
|
+
client[kKeepAliveTimeoutValue] = timeout
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout]
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
// Stop more requests from being dispatched.
|
|
722
|
+
socket[kReset] = true
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const pause = request.onResponseStart(statusCode, headers, this.resume, statusText) === false
|
|
726
|
+
|
|
727
|
+
if (request.aborted) {
|
|
728
|
+
return -1
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (request.method === 'HEAD') {
|
|
732
|
+
return 1
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (statusCode < 200) {
|
|
736
|
+
return 1
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (socket[kBlocking]) {
|
|
740
|
+
socket[kBlocking] = false
|
|
741
|
+
client[kResume]()
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
return pause ? constants.ERROR.PAUSED : 0
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @param {Buffer} buf
|
|
749
|
+
* @returns {number}
|
|
750
|
+
*/
|
|
751
|
+
onBody (buf) {
|
|
752
|
+
const { client, socket, statusCode, maxResponseSize } = this
|
|
753
|
+
|
|
754
|
+
if (socket.destroyed) {
|
|
755
|
+
return -1
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
759
|
+
assert(request)
|
|
760
|
+
|
|
761
|
+
assert(this.timeoutType === TIMEOUT_BODY)
|
|
762
|
+
if (this.timeout) {
|
|
763
|
+
if (this.timeout.refresh) {
|
|
764
|
+
this.timeout.refresh()
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
assert(statusCode >= 200)
|
|
769
|
+
|
|
770
|
+
if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
|
|
771
|
+
util.destroy(socket, new ResponseExceededMaxSizeError())
|
|
772
|
+
return -1
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
this.bytesRead += buf.length
|
|
776
|
+
|
|
777
|
+
if (request.onResponseData(buf) === false) {
|
|
778
|
+
return constants.ERROR.PAUSED
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return 0
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* @returns {number}
|
|
786
|
+
*/
|
|
787
|
+
onMessageComplete () {
|
|
788
|
+
const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this
|
|
789
|
+
|
|
790
|
+
if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
|
|
791
|
+
return -1
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if (upgrade) {
|
|
795
|
+
return 0
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
assert(statusCode >= 100)
|
|
799
|
+
assert((this.headers.length & 1) === 0)
|
|
800
|
+
|
|
801
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
802
|
+
assert(request)
|
|
803
|
+
|
|
804
|
+
this.statusCode = 0
|
|
805
|
+
this.statusText = ''
|
|
806
|
+
this.bytesRead = 0
|
|
807
|
+
this.contentLength = -1
|
|
808
|
+
this.hasTransferEncoding = false
|
|
809
|
+
this.keepAlive = ''
|
|
810
|
+
this.connection = ''
|
|
811
|
+
|
|
812
|
+
this.headers = []
|
|
813
|
+
this.headersSize = 0
|
|
814
|
+
|
|
815
|
+
if (statusCode < 200) {
|
|
816
|
+
return 0
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (contentLength !== -1 && bytesRead !== contentLength) {
|
|
820
|
+
util.destroy(socket, new ResponseContentLengthMismatchError())
|
|
821
|
+
return -1
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
request.onResponseEnd(headers)
|
|
825
|
+
|
|
826
|
+
client[kQueue][client[kRunningIdx]++] = null
|
|
827
|
+
socket[kSocketUsed] = client[kPending] === 0
|
|
828
|
+
|
|
829
|
+
if (socket[kWriting]) {
|
|
830
|
+
assert(client[kRunning] === 0)
|
|
831
|
+
// Response completed before request.
|
|
832
|
+
util.destroy(socket, new InformationalError('reset'))
|
|
833
|
+
return constants.ERROR.PAUSED
|
|
834
|
+
} else if (!shouldKeepAlive) {
|
|
835
|
+
util.destroy(socket, new InformationalError('reset'))
|
|
836
|
+
return constants.ERROR.PAUSED
|
|
837
|
+
} else if (socket[kReset] && client[kRunning] === 0) {
|
|
838
|
+
// Destroy socket once all requests have completed.
|
|
839
|
+
// The request at the tail of the pipeline is the one
|
|
840
|
+
// that requested reset and no further requests should
|
|
841
|
+
// have been queued since then.
|
|
842
|
+
util.destroy(socket, new InformationalError('reset'))
|
|
843
|
+
return constants.ERROR.PAUSED
|
|
844
|
+
} else if (client[kPipelining] == null || client[kPipelining] === 1) {
|
|
845
|
+
// We must wait a full event loop cycle to reuse this socket to make sure
|
|
846
|
+
// that non-spec compliant servers are not closing the connection even if they
|
|
847
|
+
// said they won't.
|
|
848
|
+
setImmediate(client[kResume])
|
|
849
|
+
} else {
|
|
850
|
+
client[kResume]()
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return 0
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function onParserTimeout (parserWeakRef) {
|
|
858
|
+
const parser = parserWeakRef.deref()
|
|
859
|
+
if (!parser) {
|
|
860
|
+
return
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const { socket, timeoutType, client, paused } = parser
|
|
864
|
+
|
|
865
|
+
if (timeoutType === TIMEOUT_HEADERS) {
|
|
866
|
+
if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
|
|
867
|
+
assert(!paused, 'cannot be paused while waiting for headers')
|
|
868
|
+
util.destroy(socket, new HeadersTimeoutError())
|
|
869
|
+
}
|
|
870
|
+
} else if (timeoutType === TIMEOUT_BODY) {
|
|
871
|
+
if (!paused) {
|
|
872
|
+
util.destroy(socket, new BodyTimeoutError())
|
|
873
|
+
}
|
|
874
|
+
} else if (timeoutType === TIMEOUT_KEEP_ALIVE) {
|
|
875
|
+
assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue])
|
|
876
|
+
util.destroy(socket, new InformationalError('socket idle timeout'))
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* @param {import ('./client.js')} client
|
|
882
|
+
* @param {import('net').Socket} socket
|
|
883
|
+
* @returns
|
|
884
|
+
*/
|
|
885
|
+
function connectH1 (client, socket) {
|
|
886
|
+
client[kSocket] = socket
|
|
887
|
+
|
|
888
|
+
if (!llhttpInstance) {
|
|
889
|
+
llhttpInstance = lazyllhttp()
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (socket.errored) {
|
|
893
|
+
throw socket.errored
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (socket.destroyed) {
|
|
897
|
+
throw new SocketError('destroyed')
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
socket[kNoRef] = false
|
|
901
|
+
socket[kWriting] = false
|
|
902
|
+
socket[kReset] = false
|
|
903
|
+
socket[kBlocking] = false
|
|
904
|
+
socket[kIdleSocketValidation] = 0
|
|
905
|
+
socket[kIdleSocketValidationTimeout] = null
|
|
906
|
+
socket[kSocketUsed] = false
|
|
907
|
+
socket[kParser] = typeof esbuildDetection === 'undefined' && (client[kUseMilo] ?? getMiloEnabled())
|
|
908
|
+
? new H1Parser(client, socket)
|
|
909
|
+
: new Parser(client, socket, llhttpInstance)
|
|
910
|
+
|
|
911
|
+
util.addListener(socket, 'error', onHttpSocketError)
|
|
912
|
+
util.addListener(socket, 'readable', onHttpSocketReadable)
|
|
913
|
+
util.addListener(socket, 'end', onHttpSocketEnd)
|
|
914
|
+
util.addListener(socket, 'close', onHttpSocketClose)
|
|
915
|
+
|
|
916
|
+
socket[kClosed] = false
|
|
917
|
+
socket.on('close', onSocketClose)
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
version: 'h1',
|
|
921
|
+
defaultPipelining: 1,
|
|
922
|
+
write (request) {
|
|
923
|
+
return writeH1(client, request)
|
|
924
|
+
},
|
|
925
|
+
resume () {
|
|
926
|
+
resumeH1(client)
|
|
927
|
+
},
|
|
928
|
+
/**
|
|
929
|
+
* @param {Error|undefined} err
|
|
930
|
+
* @param {() => void} callback
|
|
931
|
+
*/
|
|
932
|
+
destroy (err, callback) {
|
|
933
|
+
if (socket[kClosed]) {
|
|
934
|
+
queueMicrotask(callback)
|
|
935
|
+
} else {
|
|
936
|
+
socket.on('close', callback)
|
|
937
|
+
socket.destroy(err)
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
/**
|
|
941
|
+
* @returns {boolean}
|
|
942
|
+
*/
|
|
943
|
+
get destroyed () {
|
|
944
|
+
return socket.destroyed
|
|
945
|
+
},
|
|
946
|
+
/**
|
|
947
|
+
* @param {import('../core/request.js')} request
|
|
948
|
+
* @returns {boolean}
|
|
949
|
+
*/
|
|
950
|
+
busy (request) {
|
|
951
|
+
if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
|
|
952
|
+
return true
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
if (request) {
|
|
956
|
+
if (client[kRunning] > 0 && !request.idempotent) {
|
|
957
|
+
// Non-idempotent request cannot be retried.
|
|
958
|
+
// Ensure that no other requests are inflight and
|
|
959
|
+
// could cause failure.
|
|
960
|
+
return true
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (client[kRunning] > 0 && (request.upgrade || request.method === 'CONNECT')) {
|
|
964
|
+
// Don't dispatch an upgrade until all preceding requests have completed.
|
|
965
|
+
// A misbehaving server might upgrade the connection before all pipelined
|
|
966
|
+
// request has completed.
|
|
967
|
+
return true
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (
|
|
971
|
+
client[kRunning] > 0 &&
|
|
972
|
+
util.bodyLength(request.body) !== 0 &&
|
|
973
|
+
(util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))
|
|
974
|
+
) {
|
|
975
|
+
// Request with stream or iterator body can error while other requests
|
|
976
|
+
// are inflight and indirectly error those as well.
|
|
977
|
+
// Ensure this doesn't happen by waiting for inflight
|
|
978
|
+
// to complete before dispatching.
|
|
979
|
+
|
|
980
|
+
// Request with stream or iterator body cannot be retried.
|
|
981
|
+
// Ensure that no other requests are inflight and
|
|
982
|
+
// could cause failure.
|
|
983
|
+
return true
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
return false
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function onHttpSocketError (err) {
|
|
993
|
+
const parser = this[kParser]
|
|
994
|
+
|
|
995
|
+
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
|
996
|
+
// to the user.
|
|
997
|
+
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
|
998
|
+
const parserErr = parser.finish()
|
|
999
|
+
if (parserErr) {
|
|
1000
|
+
this[kError] = parserErr
|
|
1001
|
+
this[kClient][kOnError](parserErr)
|
|
1002
|
+
}
|
|
1003
|
+
return
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
this[kError] = err
|
|
1007
|
+
|
|
1008
|
+
this[kClient][kOnError](err)
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function onHttpSocketReadable () {
|
|
1012
|
+
this[kParser]?.readMore()
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
function onHttpSocketEnd () {
|
|
1016
|
+
const parser = this[kParser]
|
|
1017
|
+
|
|
1018
|
+
if (parser.statusCode && !parser.shouldKeepAlive) {
|
|
1019
|
+
const parserErr = parser.finish()
|
|
1020
|
+
if (parserErr) {
|
|
1021
|
+
util.destroy(this, parserErr)
|
|
1022
|
+
}
|
|
1023
|
+
return
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)))
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
function onHttpSocketClose () {
|
|
1030
|
+
const parser = this[kParser]
|
|
1031
|
+
|
|
1032
|
+
clearIdleSocketValidation(this)
|
|
1033
|
+
|
|
1034
|
+
if (parser) {
|
|
1035
|
+
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
|
1036
|
+
this[kError] = parser.finish() || this[kError]
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
this[kParser].destroy()
|
|
1040
|
+
this[kParser] = null
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
const err = this[kError] || new SocketError('closed', util.getSocketInfo(this))
|
|
1044
|
+
|
|
1045
|
+
const client = this[kClient]
|
|
1046
|
+
|
|
1047
|
+
client[kSocket] = null
|
|
1048
|
+
client[kHTTPContext] = null // TODO (fix): This is hacky...
|
|
1049
|
+
|
|
1050
|
+
if (client.destroyed) {
|
|
1051
|
+
assert(client[kPending] === 0)
|
|
1052
|
+
|
|
1053
|
+
// Fail entire queue.
|
|
1054
|
+
const requests = client[kQueue].splice(client[kRunningIdx])
|
|
1055
|
+
for (let i = 0; i < requests.length; i++) {
|
|
1056
|
+
const request = requests[i]
|
|
1057
|
+
util.errorRequest(client, request, err)
|
|
1058
|
+
}
|
|
1059
|
+
} else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') {
|
|
1060
|
+
// Fail head of pipeline.
|
|
1061
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
1062
|
+
client[kQueue][client[kRunningIdx]++] = null
|
|
1063
|
+
|
|
1064
|
+
util.errorRequest(client, request, err)
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
client[kPendingIdx] = client[kRunningIdx]
|
|
1068
|
+
|
|
1069
|
+
assert(client[kRunning] === 0)
|
|
1070
|
+
|
|
1071
|
+
client.emit('disconnect', client[kUrl], [client], err)
|
|
1072
|
+
|
|
1073
|
+
client[kResume]()
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function onSocketClose () {
|
|
1077
|
+
this[kClosed] = true
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function clearIdleSocketValidation (socket) {
|
|
1081
|
+
if (socket[kIdleSocketValidationTimeout]) {
|
|
1082
|
+
clearImmediate(socket[kIdleSocketValidationTimeout])
|
|
1083
|
+
socket[kIdleSocketValidationTimeout] = null
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
socket[kIdleSocketValidation] = 0
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
function scheduleIdleSocketValidation (client, socket) {
|
|
1090
|
+
socket[kIdleSocketValidation] = 1
|
|
1091
|
+
// Yield to the check phase (after poll) so unsolicited bytes / FIN / RST
|
|
1092
|
+
// already pending on this idle keep-alive socket are processed before the
|
|
1093
|
+
// next request is written (GHSA-35p6-xmwp-9g52).
|
|
1094
|
+
//
|
|
1095
|
+
// setTimeout(0) pays Node's ~1ms timer floor on every sequential reuse
|
|
1096
|
+
// (#5493). setImmediate avoids that, but an *unref'd* Immediate lets poll
|
|
1097
|
+
// block for ~500ms when the event loop is otherwise idle (#5600 / #5606).
|
|
1098
|
+
// A ref'd Immediate both keeps the pending request alive and makes poll
|
|
1099
|
+
// return immediately — the hybrid those issues asked for.
|
|
1100
|
+
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
|
|
1101
|
+
socket[kIdleSocketValidationTimeout] = null
|
|
1102
|
+
socket[kIdleSocketValidation] = 2
|
|
1103
|
+
|
|
1104
|
+
if (client[kSocket] === socket && !socket.destroyed) {
|
|
1105
|
+
client[kResume]()
|
|
1106
|
+
}
|
|
1107
|
+
})
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* @param {import('./client.js')} client
|
|
1112
|
+
*/
|
|
1113
|
+
function resumeH1 (client) {
|
|
1114
|
+
const socket = client[kSocket]
|
|
1115
|
+
|
|
1116
|
+
if (socket && !socket.destroyed) {
|
|
1117
|
+
if (client[kSize] === 0) {
|
|
1118
|
+
if (!socket[kNoRef] && socket.unref) {
|
|
1119
|
+
socket.unref()
|
|
1120
|
+
socket[kNoRef] = true
|
|
1121
|
+
}
|
|
1122
|
+
} else if (socket[kNoRef] && socket.ref) {
|
|
1123
|
+
socket.ref()
|
|
1124
|
+
socket[kNoRef] = false
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
|
|
1128
|
+
if (socket[kIdleSocketValidation] === 0) {
|
|
1129
|
+
scheduleIdleSocketValidation(client, socket)
|
|
1130
|
+
socket[kParser].readMore()
|
|
1131
|
+
if (socket.destroyed) {
|
|
1132
|
+
return
|
|
1133
|
+
}
|
|
1134
|
+
return
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
if (socket[kIdleSocketValidation] === 1) {
|
|
1138
|
+
socket[kParser].readMore()
|
|
1139
|
+
if (socket.destroyed) {
|
|
1140
|
+
return
|
|
1141
|
+
}
|
|
1142
|
+
return
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
if (client[kRunning] === 0) {
|
|
1147
|
+
socket[kParser].readMore()
|
|
1148
|
+
if (socket.destroyed) {
|
|
1149
|
+
return
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
if (client[kSize] === 0) {
|
|
1154
|
+
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
|
1155
|
+
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
|
1156
|
+
}
|
|
1157
|
+
} else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
|
|
1158
|
+
if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
|
|
1159
|
+
const request = client[kQueue][client[kRunningIdx]]
|
|
1160
|
+
const headersTimeout = request.headersTimeout != null ? request.headersTimeout : client[kHeadersTimeout]
|
|
1161
|
+
socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS)
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
|
|
1168
|
+
function shouldSendContentLength (method) {
|
|
1169
|
+
return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function setTypeOfService (socket, request) {
|
|
1173
|
+
if (typeof socket.setTypeOfService !== 'function') {
|
|
1174
|
+
return
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
const typeOfService = request.typeOfService
|
|
1178
|
+
|
|
1179
|
+
if (typeOfService === undefined) {
|
|
1180
|
+
return
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
const currentTypeOfService = socket[kTypeOfService]
|
|
1184
|
+
|
|
1185
|
+
if (currentTypeOfService === typeOfService) {
|
|
1186
|
+
return
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
try {
|
|
1190
|
+
socket.setTypeOfService(typeOfService)
|
|
1191
|
+
socket[kTypeOfService] = typeOfService
|
|
1192
|
+
} catch {
|
|
1193
|
+
// QoS marking is best-effort. setTypeOfService() can throw synchronously on
|
|
1194
|
+
// some platforms depending on socket state, but that must not abort the request.
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* @param {import('./client.js')} client
|
|
1200
|
+
* @param {import('../core/request.js')} request
|
|
1201
|
+
* @returns
|
|
1202
|
+
*/
|
|
1203
|
+
function writeH1 (client, request) {
|
|
1204
|
+
const { method, path, host, upgrade, blocking, reset } = request
|
|
1205
|
+
|
|
1206
|
+
let { body, headers, contentLength } = request
|
|
1207
|
+
|
|
1208
|
+
// https://tools.ietf.org/html/rfc7231#section-4.3.1
|
|
1209
|
+
// https://tools.ietf.org/html/rfc7231#section-4.3.2
|
|
1210
|
+
// https://tools.ietf.org/html/rfc7231#section-4.3.5
|
|
1211
|
+
|
|
1212
|
+
// Sending a payload body on a request that does not
|
|
1213
|
+
// expect it can cause undefined behavior on some
|
|
1214
|
+
// servers and corrupt connection state. Do not
|
|
1215
|
+
// re-use the connection for further requests.
|
|
1216
|
+
|
|
1217
|
+
const expectsPayload =
|
|
1218
|
+
method === 'PUT' ||
|
|
1219
|
+
method === 'POST' ||
|
|
1220
|
+
method === 'PATCH' ||
|
|
1221
|
+
method === 'QUERY' ||
|
|
1222
|
+
method === 'PROPFIND' ||
|
|
1223
|
+
method === 'PROPPATCH'
|
|
1224
|
+
|
|
1225
|
+
if (util.isFormDataLike(body)) {
|
|
1226
|
+
if (!extractBody) {
|
|
1227
|
+
extractBody = require('../web/fetch/body.js').extractBody
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
const [bodyStream, contentType] = extractBody(body)
|
|
1231
|
+
if (request.contentType == null) {
|
|
1232
|
+
headers.push('content-type', contentType)
|
|
1233
|
+
}
|
|
1234
|
+
body = bodyStream.stream
|
|
1235
|
+
contentLength = bodyStream.length
|
|
1236
|
+
} else if (util.isBlobLike(body) && request.contentType == null) {
|
|
1237
|
+
const contentType = body.type
|
|
1238
|
+
if (contentType) {
|
|
1239
|
+
const contentTypeValue = `${contentType}`
|
|
1240
|
+
if (!util.isValidHeaderValue(contentTypeValue)) {
|
|
1241
|
+
util.errorRequest(client, request, new InvalidArgumentError('invalid content-type header'))
|
|
1242
|
+
return false
|
|
1243
|
+
}
|
|
1244
|
+
headers.push('content-type', contentTypeValue)
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
if (body && typeof body.read === 'function') {
|
|
1249
|
+
// Try to read EOF in order to get length.
|
|
1250
|
+
body.read(0)
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
const bodyLength = util.bodyLength(body)
|
|
1254
|
+
|
|
1255
|
+
contentLength = bodyLength ?? contentLength
|
|
1256
|
+
|
|
1257
|
+
if (contentLength === null) {
|
|
1258
|
+
contentLength = request.contentLength
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (contentLength === 0 && !expectsPayload) {
|
|
1262
|
+
// https://tools.ietf.org/html/rfc7230#section-3.3.2
|
|
1263
|
+
// A user agent SHOULD NOT send a Content-Length header field when
|
|
1264
|
+
// the request message does not contain a payload body and the method
|
|
1265
|
+
// semantics do not anticipate such a body.
|
|
1266
|
+
|
|
1267
|
+
contentLength = null
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// https://github.com/nodejs/undici/issues/2046
|
|
1271
|
+
// A user agent may send a Content-Length header with 0 value, this should be allowed.
|
|
1272
|
+
if (
|
|
1273
|
+
shouldSendContentLength(method) &&
|
|
1274
|
+
contentLength > 0 &&
|
|
1275
|
+
request.contentLength !== null &&
|
|
1276
|
+
request.contentLength !== contentLength
|
|
1277
|
+
) {
|
|
1278
|
+
if (client[kStrictContentLength]) {
|
|
1279
|
+
util.errorRequest(client, request, new RequestContentLengthMismatchError())
|
|
1280
|
+
return false
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
process.emitWarning(new RequestContentLengthMismatchError())
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
const socket = client[kSocket]
|
|
1287
|
+
clearIdleSocketValidation(socket)
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* @param {Error} [err]
|
|
1291
|
+
* @returns {void}
|
|
1292
|
+
*/
|
|
1293
|
+
const abort = err => {
|
|
1294
|
+
if (request.aborted || request.completed) {
|
|
1295
|
+
return
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
util.errorRequest(client, request, err || new RequestAbortedError())
|
|
1299
|
+
|
|
1300
|
+
util.destroy(body)
|
|
1301
|
+
util.destroy(socket, new InformationalError('aborted'))
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
try {
|
|
1305
|
+
request.onRequestStart(abort, null)
|
|
1306
|
+
} catch (err) {
|
|
1307
|
+
util.errorRequest(client, request, err)
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
if (request.aborted) {
|
|
1311
|
+
return false
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
if (method === 'HEAD') {
|
|
1315
|
+
// https://github.com/mcollina/undici/issues/258
|
|
1316
|
+
// Close after a HEAD request to interop with misbehaving servers
|
|
1317
|
+
// that may send a body in the response.
|
|
1318
|
+
|
|
1319
|
+
socket[kReset] = true
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
if (upgrade || method === 'CONNECT') {
|
|
1323
|
+
// On CONNECT or upgrade, block pipeline from dispatching further
|
|
1324
|
+
// requests on this connection.
|
|
1325
|
+
|
|
1326
|
+
socket[kReset] = true
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if (reset != null) {
|
|
1330
|
+
socket[kReset] = reset
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
if (client[kMaxRequests] && ++socket[kCounter] >= client[kMaxRequests]) {
|
|
1334
|
+
socket[kReset] = true
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
if (blocking) {
|
|
1338
|
+
socket[kBlocking] = true
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
setTypeOfService(socket, request)
|
|
1342
|
+
|
|
1343
|
+
let header = `${method} ${path} HTTP/1.1\r\n`
|
|
1344
|
+
|
|
1345
|
+
if (typeof host === 'string') {
|
|
1346
|
+
header += `host: ${host}\r\n`
|
|
1347
|
+
} else {
|
|
1348
|
+
header += client[kHostHeader]
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
if (upgrade) {
|
|
1352
|
+
header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`
|
|
1353
|
+
} else if (client[kPipelining] && !socket[kReset]) {
|
|
1354
|
+
header += 'connection: keep-alive\r\n'
|
|
1355
|
+
} else {
|
|
1356
|
+
header += 'connection: close\r\n'
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
if (Array.isArray(headers)) {
|
|
1360
|
+
for (let n = 0; n < headers.length; n += 2) {
|
|
1361
|
+
const key = headers[n + 0]
|
|
1362
|
+
const val = headers[n + 1]
|
|
1363
|
+
|
|
1364
|
+
if (Array.isArray(val)) {
|
|
1365
|
+
for (let i = 0; i < val.length; i++) {
|
|
1366
|
+
header += `${key}: ${val[i]}\r\n`
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
header += `${key}: ${val}\r\n`
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
if (channels.sendHeaders.hasSubscribers) {
|
|
1375
|
+
channels.sendHeaders.publish({ request, headers: header, socket })
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
if (!body || bodyLength === 0) {
|
|
1379
|
+
writeBuffer(abort, null, client, request, socket, contentLength, header, expectsPayload)
|
|
1380
|
+
} else if (util.isBuffer(body)) {
|
|
1381
|
+
writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload)
|
|
1382
|
+
} else if (util.isBlobLike(body)) {
|
|
1383
|
+
if (typeof body.stream === 'function') {
|
|
1384
|
+
writeIterable(abort, body.stream(), client, request, socket, contentLength, header, expectsPayload)
|
|
1385
|
+
} else {
|
|
1386
|
+
writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload)
|
|
1387
|
+
}
|
|
1388
|
+
} else if (util.isStream(body)) {
|
|
1389
|
+
writeStream(abort, body, client, request, socket, contentLength, header, expectsPayload)
|
|
1390
|
+
} else if (util.isIterable(body)) {
|
|
1391
|
+
writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload)
|
|
1392
|
+
} else {
|
|
1393
|
+
assert(false)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
return true
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* @param {AbortCallback} abort
|
|
1401
|
+
* @param {import('stream').Stream} body
|
|
1402
|
+
* @param {import('./client.js')} client
|
|
1403
|
+
* @param {import('../core/request.js')} request
|
|
1404
|
+
* @param {import('net').Socket} socket
|
|
1405
|
+
* @param {number} contentLength
|
|
1406
|
+
* @param {string} header
|
|
1407
|
+
* @param {boolean} expectsPayload
|
|
1408
|
+
*/
|
|
1409
|
+
function writeStream (abort, body, client, request, socket, contentLength, header, expectsPayload) {
|
|
1410
|
+
assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined')
|
|
1411
|
+
|
|
1412
|
+
let finished = false
|
|
1413
|
+
|
|
1414
|
+
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* @param {Buffer} chunk
|
|
1418
|
+
* @returns {void}
|
|
1419
|
+
*/
|
|
1420
|
+
const onData = function (chunk) {
|
|
1421
|
+
if (finished) {
|
|
1422
|
+
return
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
try {
|
|
1426
|
+
if (!writer.write(chunk) && this.pause) {
|
|
1427
|
+
this.pause()
|
|
1428
|
+
}
|
|
1429
|
+
} catch (err) {
|
|
1430
|
+
util.destroy(this, err)
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* @returns {void}
|
|
1436
|
+
*/
|
|
1437
|
+
const onDrain = function () {
|
|
1438
|
+
if (finished) {
|
|
1439
|
+
return
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
if (body.resume) {
|
|
1443
|
+
body.resume()
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* @returns {void}
|
|
1449
|
+
*/
|
|
1450
|
+
const onClose = function () {
|
|
1451
|
+
// 'close' might be emitted *before* 'error' for
|
|
1452
|
+
// broken streams. Wait a tick to avoid this case.
|
|
1453
|
+
queueMicrotask(() => {
|
|
1454
|
+
// It's only safe to remove 'error' listener after
|
|
1455
|
+
// 'close'.
|
|
1456
|
+
body.removeListener('error', onFinished)
|
|
1457
|
+
})
|
|
1458
|
+
|
|
1459
|
+
if (!finished) {
|
|
1460
|
+
const err = new RequestAbortedError()
|
|
1461
|
+
queueMicrotask(() => onFinished(err))
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* @param {Error} [err]
|
|
1467
|
+
* @returns
|
|
1468
|
+
*/
|
|
1469
|
+
const onFinished = function (err) {
|
|
1470
|
+
if (finished) {
|
|
1471
|
+
return
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
finished = true
|
|
1475
|
+
|
|
1476
|
+
assert(socket.destroyed || (socket[kWriting] && client[kRunning] <= 1))
|
|
1477
|
+
|
|
1478
|
+
socket.off('drain', onDrain).off('error', onFinished)
|
|
1479
|
+
|
|
1480
|
+
body.removeListener('data', onData).removeListener('end', onFinished).removeListener('close', onClose)
|
|
1481
|
+
|
|
1482
|
+
if (!err) {
|
|
1483
|
+
try {
|
|
1484
|
+
writer.end()
|
|
1485
|
+
} catch (er) {
|
|
1486
|
+
err = er
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
writer.destroy(err)
|
|
1491
|
+
|
|
1492
|
+
if (err && (err.code !== 'UND_ERR_INFO' || err.message !== 'reset')) {
|
|
1493
|
+
util.destroy(body, err)
|
|
1494
|
+
} else {
|
|
1495
|
+
util.destroy(body)
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
body.on('data', onData).on('end', onFinished).on('error', onFinished).on('close', onClose)
|
|
1500
|
+
|
|
1501
|
+
if (body.resume) {
|
|
1502
|
+
body.resume()
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
socket.on('drain', onDrain).on('error', onFinished)
|
|
1506
|
+
|
|
1507
|
+
if (body.errorEmitted ?? body.errored) {
|
|
1508
|
+
setImmediate(onFinished, body.errored)
|
|
1509
|
+
} else if (body.endEmitted ?? body.readableEnded) {
|
|
1510
|
+
setImmediate(onFinished, null)
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
if (body.closeEmitted ?? body.closed) {
|
|
1514
|
+
setImmediate(onClose)
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* @typedef AbortCallback
|
|
1520
|
+
* @type {Function}
|
|
1521
|
+
* @param {Error} [err]
|
|
1522
|
+
* @returns {void}
|
|
1523
|
+
*/
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* @param {AbortCallback} abort
|
|
1527
|
+
* @param {Uint8Array|null} body
|
|
1528
|
+
* @param {import('./client.js')} client
|
|
1529
|
+
* @param {import('../core/request.js')} request
|
|
1530
|
+
* @param {import('net').Socket} socket
|
|
1531
|
+
* @param {number} contentLength
|
|
1532
|
+
* @param {string} header
|
|
1533
|
+
* @param {boolean} expectsPayload
|
|
1534
|
+
* @returns {void}
|
|
1535
|
+
*/
|
|
1536
|
+
function writeBuffer (abort, body, client, request, socket, contentLength, header, expectsPayload) {
|
|
1537
|
+
try {
|
|
1538
|
+
if (!body) {
|
|
1539
|
+
if (contentLength === 0) {
|
|
1540
|
+
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
|
1541
|
+
} else {
|
|
1542
|
+
assert(contentLength === null, 'no body must not have content length')
|
|
1543
|
+
socket.write(`${header}\r\n`, 'latin1')
|
|
1544
|
+
}
|
|
1545
|
+
} else if (util.isBuffer(body)) {
|
|
1546
|
+
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
|
1547
|
+
|
|
1548
|
+
socket.cork()
|
|
1549
|
+
socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|
1550
|
+
socket.write(body)
|
|
1551
|
+
socket.uncork()
|
|
1552
|
+
request.onBodySent(body)
|
|
1553
|
+
|
|
1554
|
+
if (!expectsPayload && request.reset !== false) {
|
|
1555
|
+
socket[kReset] = true
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
request.onRequestSent()
|
|
1559
|
+
|
|
1560
|
+
client[kResume]()
|
|
1561
|
+
} catch (err) {
|
|
1562
|
+
abort(err)
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* @param {AbortCallback} abort
|
|
1568
|
+
* @param {Blob} body
|
|
1569
|
+
* @param {import('./client.js')} client
|
|
1570
|
+
* @param {import('../core/request.js')} request
|
|
1571
|
+
* @param {import('net').Socket} socket
|
|
1572
|
+
* @param {number} contentLength
|
|
1573
|
+
* @param {string} header
|
|
1574
|
+
* @param {boolean} expectsPayload
|
|
1575
|
+
* @returns {Promise<void>}
|
|
1576
|
+
*/
|
|
1577
|
+
async function writeBlob (abort, body, client, request, socket, contentLength, header, expectsPayload) {
|
|
1578
|
+
try {
|
|
1579
|
+
if (contentLength != null && contentLength !== body.size) {
|
|
1580
|
+
throw new RequestContentLengthMismatchError()
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
const buffer = Buffer.from(await body.arrayBuffer())
|
|
1584
|
+
|
|
1585
|
+
socket.cork()
|
|
1586
|
+
socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|
1587
|
+
socket.write(buffer)
|
|
1588
|
+
socket.uncork()
|
|
1589
|
+
|
|
1590
|
+
request.onBodySent(buffer)
|
|
1591
|
+
request.onRequestSent()
|
|
1592
|
+
|
|
1593
|
+
if (!expectsPayload && request.reset !== false) {
|
|
1594
|
+
socket[kReset] = true
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
client[kResume]()
|
|
1598
|
+
} catch (err) {
|
|
1599
|
+
abort(err)
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* @param {AbortCallback} abort
|
|
1605
|
+
* @param {Iterable} body
|
|
1606
|
+
* @param {import('./client.js')} client
|
|
1607
|
+
* @param {import('../core/request.js')} request
|
|
1608
|
+
* @param {import('net').Socket} socket
|
|
1609
|
+
* @param {number} contentLength
|
|
1610
|
+
* @param {string} header
|
|
1611
|
+
* @param {boolean} expectsPayload
|
|
1612
|
+
* @returns {Promise<void>}
|
|
1613
|
+
*/
|
|
1614
|
+
async function writeIterable (abort, body, client, request, socket, contentLength, header, expectsPayload) {
|
|
1615
|
+
assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined')
|
|
1616
|
+
|
|
1617
|
+
let callback = null
|
|
1618
|
+
function onDrain () {
|
|
1619
|
+
if (callback) {
|
|
1620
|
+
const cb = callback
|
|
1621
|
+
callback = null
|
|
1622
|
+
cb()
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
const waitForDrain = () =>
|
|
1627
|
+
new Promise((resolve, reject) => {
|
|
1628
|
+
assert(callback === null)
|
|
1629
|
+
|
|
1630
|
+
if (socket[kError]) {
|
|
1631
|
+
reject(socket[kError])
|
|
1632
|
+
} else {
|
|
1633
|
+
callback = resolve
|
|
1634
|
+
}
|
|
1635
|
+
})
|
|
1636
|
+
|
|
1637
|
+
socket.on('close', onDrain).on('drain', onDrain)
|
|
1638
|
+
|
|
1639
|
+
const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
|
|
1640
|
+
try {
|
|
1641
|
+
// It's up to the user to somehow abort the async iterable.
|
|
1642
|
+
for await (const chunk of body) {
|
|
1643
|
+
if (socket[kError]) {
|
|
1644
|
+
throw socket[kError]
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
if (!writer.write(chunk)) {
|
|
1648
|
+
await waitForDrain()
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
writer.end()
|
|
1653
|
+
} catch (err) {
|
|
1654
|
+
writer.destroy(err)
|
|
1655
|
+
} finally {
|
|
1656
|
+
socket.off('close', onDrain).off('drain', onDrain)
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
class AsyncWriter {
|
|
1661
|
+
/**
|
|
1662
|
+
*
|
|
1663
|
+
* @param {object} arg
|
|
1664
|
+
* @param {AbortCallback} arg.abort
|
|
1665
|
+
* @param {import('net').Socket} arg.socket
|
|
1666
|
+
* @param {import('../core/request.js')} arg.request
|
|
1667
|
+
* @param {number} arg.contentLength
|
|
1668
|
+
* @param {import('./client.js')} arg.client
|
|
1669
|
+
* @param {boolean} arg.expectsPayload
|
|
1670
|
+
* @param {string} arg.header
|
|
1671
|
+
*/
|
|
1672
|
+
constructor ({ abort, socket, request, contentLength, client, expectsPayload, header }) {
|
|
1673
|
+
this.socket = socket
|
|
1674
|
+
this.request = request
|
|
1675
|
+
this.contentLength = contentLength
|
|
1676
|
+
this.client = client
|
|
1677
|
+
this.bytesWritten = 0
|
|
1678
|
+
this.expectsPayload = expectsPayload
|
|
1679
|
+
this.header = header
|
|
1680
|
+
this.abort = abort
|
|
1681
|
+
this.lengthMismatch = false
|
|
1682
|
+
|
|
1683
|
+
socket[kWriting] = true
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* The body doesn't match the declared content-length and strictContentLength
|
|
1688
|
+
* is off. Warn once, and mark the socket so it isn't reused: on the wire this
|
|
1689
|
+
* request's body no longer ends where the server expects, so anything sent
|
|
1690
|
+
* after it on the same connection would be misread.
|
|
1691
|
+
* @returns {void}
|
|
1692
|
+
*/
|
|
1693
|
+
onLengthMismatch () {
|
|
1694
|
+
this.socket[kReset] = true
|
|
1695
|
+
|
|
1696
|
+
if (!this.lengthMismatch) {
|
|
1697
|
+
this.lengthMismatch = true
|
|
1698
|
+
process.emitWarning(new RequestContentLengthMismatchError())
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
/**
|
|
1703
|
+
* @param {string|Uint8Array} chunk
|
|
1704
|
+
* @returns
|
|
1705
|
+
*/
|
|
1706
|
+
write (chunk) {
|
|
1707
|
+
const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this
|
|
1708
|
+
|
|
1709
|
+
if (socket[kError]) {
|
|
1710
|
+
throw socket[kError]
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
if (socket.destroyed) {
|
|
1714
|
+
return false
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
let len = chunk instanceof Uint8Array ? chunk.byteLength : Buffer.byteLength(chunk)
|
|
1718
|
+
if (!len) {
|
|
1719
|
+
return true
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// We should defer writing chunks.
|
|
1723
|
+
if (contentLength !== null && bytesWritten + len > contentLength) {
|
|
1724
|
+
if (client[kStrictContentLength]) {
|
|
1725
|
+
throw new RequestContentLengthMismatchError()
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
this.onLengthMismatch()
|
|
1729
|
+
|
|
1730
|
+
// Never write past the declared content-length. The server treats any
|
|
1731
|
+
// extra bytes as the start of the next request, so a body could inject
|
|
1732
|
+
// a request of its own (request smuggling).
|
|
1733
|
+
const remaining = contentLength - bytesWritten
|
|
1734
|
+
if (remaining === 0) {
|
|
1735
|
+
return true
|
|
1736
|
+
}
|
|
1737
|
+
chunk = (typeof chunk === 'string' ? Buffer.from(chunk) : chunk).subarray(0, remaining)
|
|
1738
|
+
len = remaining
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
socket.cork()
|
|
1742
|
+
|
|
1743
|
+
if (bytesWritten === 0) {
|
|
1744
|
+
if (!expectsPayload && request.reset !== false) {
|
|
1745
|
+
socket[kReset] = true
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
if (contentLength === null) {
|
|
1749
|
+
socket.write(`${header}transfer-encoding: chunked\r\n`, 'latin1')
|
|
1750
|
+
} else {
|
|
1751
|
+
socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
if (contentLength === null) {
|
|
1756
|
+
socket.write(`\r\n${len.toString(16)}\r\n`, 'latin1')
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
this.bytesWritten += len
|
|
1760
|
+
|
|
1761
|
+
const ret = socket.write(chunk)
|
|
1762
|
+
|
|
1763
|
+
socket.uncork()
|
|
1764
|
+
|
|
1765
|
+
request.onBodySent(chunk)
|
|
1766
|
+
|
|
1767
|
+
if (!ret) {
|
|
1768
|
+
if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
|
|
1769
|
+
if (socket[kParser].timeout.refresh) {
|
|
1770
|
+
socket[kParser].timeout.refresh()
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
return ret
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* @returns {void}
|
|
1780
|
+
*/
|
|
1781
|
+
end () {
|
|
1782
|
+
const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this
|
|
1783
|
+
request.onRequestSent()
|
|
1784
|
+
|
|
1785
|
+
socket[kWriting] = false
|
|
1786
|
+
|
|
1787
|
+
if (socket[kError]) {
|
|
1788
|
+
throw socket[kError]
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
if (socket.destroyed) {
|
|
1792
|
+
return
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
if (bytesWritten === 0) {
|
|
1796
|
+
if (expectsPayload) {
|
|
1797
|
+
// https://tools.ietf.org/html/rfc7230#section-3.3.2
|
|
1798
|
+
// A user agent SHOULD send a Content-Length in a request message when
|
|
1799
|
+
// no Transfer-Encoding is sent and the request method defines a meaning
|
|
1800
|
+
// for an enclosed payload body.
|
|
1801
|
+
|
|
1802
|
+
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
|
1803
|
+
} else {
|
|
1804
|
+
socket.write(`${header}\r\n`, 'latin1')
|
|
1805
|
+
}
|
|
1806
|
+
} else if (contentLength === null) {
|
|
1807
|
+
socket.write('\r\n0\r\n\r\n', 'latin1')
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
if (contentLength !== null && bytesWritten !== contentLength) {
|
|
1811
|
+
if (client[kStrictContentLength]) {
|
|
1812
|
+
throw new RequestContentLengthMismatchError()
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
// The body is shorter than declared, so the server is still waiting for
|
|
1816
|
+
// the rest. Don't let the next request's bytes on this connection be
|
|
1817
|
+
// read as the missing part of this body.
|
|
1818
|
+
this.onLengthMismatch()
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
|
|
1822
|
+
if (socket[kParser].timeout.refresh) {
|
|
1823
|
+
socket[kParser].timeout.refresh()
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
client[kResume]()
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* @param {Error} [err]
|
|
1832
|
+
* @returns {void}
|
|
1833
|
+
*/
|
|
1834
|
+
destroy (err) {
|
|
1835
|
+
const { socket, client, abort } = this
|
|
1836
|
+
|
|
1837
|
+
socket[kWriting] = false
|
|
1838
|
+
|
|
1839
|
+
if (err) {
|
|
1840
|
+
assert(client[kRunning] <= 1, 'pipeline should only contain this request')
|
|
1841
|
+
abort(err)
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
module.exports = connectH1
|