@relative-ci/core 5.2.2-beta.0 → 5.3.0-alpha.0

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.
Files changed (610) hide show
  1. package/lib/cjs/__/@actions/github/__/@octokit/auth-token/dist-bundle/index.js +57 -0
  2. package/lib/cjs/__/@actions/github/__/@octokit/auth-token/dist-bundle/index.js.map +1 -0
  3. package/lib/cjs/__/@actions/github/__/@octokit/core/dist-src/index.js +144 -0
  4. package/lib/cjs/__/@actions/github/__/@octokit/core/dist-src/index.js.map +1 -0
  5. package/lib/cjs/__/@actions/github/__/@octokit/core/dist-src/version.js +6 -0
  6. package/lib/cjs/__/@actions/github/__/@octokit/core/dist-src/version.js.map +1 -0
  7. package/lib/cjs/__/@actions/github/__/@octokit/endpoint/dist-bundle/index.js +349 -0
  8. package/lib/cjs/__/@actions/github/__/@octokit/endpoint/dist-bundle/index.js.map +1 -0
  9. package/lib/cjs/__/@actions/github/__/@octokit/graphql/dist-bundle/index.js +125 -0
  10. package/lib/cjs/__/@actions/github/__/@octokit/graphql/dist-bundle/index.js.map +1 -0
  11. package/lib/cjs/__/@actions/github/__/@octokit/plugin-paginate-rest/dist-bundle/index.js +417 -0
  12. package/lib/cjs/__/@actions/github/__/@octokit/plugin-paginate-rest/dist-bundle/index.js.map +1 -0
  13. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +128 -0
  14. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js.map +1 -0
  15. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +2295 -0
  16. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js.map +1 -0
  17. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +24 -0
  18. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/index.js.map +1 -0
  19. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +6 -0
  20. package/lib/cjs/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/version.js.map +1 -0
  21. package/lib/cjs/__/@actions/github/__/@octokit/request/dist-bundle/index.js +199 -0
  22. package/lib/cjs/__/@actions/github/__/@octokit/request/dist-bundle/index.js.map +1 -0
  23. package/lib/cjs/__/@actions/github/__/@octokit/request-error/dist-src/index.js +43 -0
  24. package/lib/cjs/__/@actions/github/__/@octokit/request-error/dist-src/index.js.map +1 -0
  25. package/lib/cjs/__/@actions/github/__/before-after-hook/index.js +41 -0
  26. package/lib/cjs/__/@actions/github/__/before-after-hook/index.js.map +1 -0
  27. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/add.js +51 -0
  28. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/add.js.map +1 -0
  29. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/register.js +32 -0
  30. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/register.js.map +1 -0
  31. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/remove.js +24 -0
  32. package/lib/cjs/__/@actions/github/__/before-after-hook/lib/remove.js.map +1 -0
  33. package/lib/cjs/__/@actions/github/__/universal-user-agent/index.js +18 -0
  34. package/lib/cjs/__/@actions/github/__/universal-user-agent/index.js.map +1 -0
  35. package/lib/cjs/__/@actions/github/lib/context.js +76 -0
  36. package/lib/cjs/__/@actions/github/lib/context.js.map +1 -0
  37. package/lib/cjs/__/@actions/github/lib/github.js +66 -0
  38. package/lib/cjs/__/@actions/github/lib/github.js.map +1 -0
  39. package/lib/cjs/__/@actions/github/lib/internal/utils.js +94 -0
  40. package/lib/cjs/__/@actions/github/lib/internal/utils.js.map +1 -0
  41. package/lib/cjs/__/@actions/github/lib/utils.js +89 -0
  42. package/lib/cjs/__/@actions/github/lib/utils.js.map +1 -0
  43. package/lib/cjs/__/@actions/http-client/lib/index.js +760 -0
  44. package/lib/cjs/__/@actions/http-client/lib/index.js.map +1 -0
  45. package/lib/cjs/__/@actions/http-client/lib/proxy.js +107 -0
  46. package/lib/cjs/__/@actions/http-client/lib/proxy.js.map +1 -0
  47. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/Dicer.js +236 -0
  48. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/Dicer.js.map +1 -0
  49. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/HeaderParser.js +122 -0
  50. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/HeaderParser.js.map +1 -0
  51. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/PartStream.js +33 -0
  52. package/lib/cjs/__/@fastify/busboy/deps/dicer/lib/PartStream.js.map +1 -0
  53. package/lib/cjs/__/@fastify/busboy/deps/streamsearch/sbmh.js +248 -0
  54. package/lib/cjs/__/@fastify/busboy/deps/streamsearch/sbmh.js.map +1 -0
  55. package/lib/cjs/__/@fastify/busboy/lib/main.js +109 -0
  56. package/lib/cjs/__/@fastify/busboy/lib/main.js.map +1 -0
  57. package/lib/cjs/__/@fastify/busboy/lib/types/multipart.js +331 -0
  58. package/lib/cjs/__/@fastify/busboy/lib/types/multipart.js.map +1 -0
  59. package/lib/cjs/__/@fastify/busboy/lib/types/urlencoded.js +206 -0
  60. package/lib/cjs/__/@fastify/busboy/lib/types/urlencoded.js.map +1 -0
  61. package/lib/cjs/__/@fastify/busboy/lib/utils/Decoder.js +66 -0
  62. package/lib/cjs/__/@fastify/busboy/lib/utils/Decoder.js.map +1 -0
  63. package/lib/cjs/__/@fastify/busboy/lib/utils/basename.js +26 -0
  64. package/lib/cjs/__/@fastify/busboy/lib/utils/basename.js.map +1 -0
  65. package/lib/cjs/__/@fastify/busboy/lib/utils/decodeText.js +126 -0
  66. package/lib/cjs/__/@fastify/busboy/lib/utils/decodeText.js.map +1 -0
  67. package/lib/cjs/__/@fastify/busboy/lib/utils/getLimit.js +28 -0
  68. package/lib/cjs/__/@fastify/busboy/lib/utils/getLimit.js.map +1 -0
  69. package/lib/cjs/__/@fastify/busboy/lib/utils/parseParams.js +211 -0
  70. package/lib/cjs/__/@fastify/busboy/lib/utils/parseParams.js.map +1 -0
  71. package/lib/cjs/__/cross-spawn/index.js +1 -1
  72. package/lib/cjs/__/env-ci/__/execa/index.js +3 -3
  73. package/lib/cjs/__/env-ci/__/execa/index.js.map +1 -1
  74. package/lib/cjs/__/env-ci/__/execa/lib/stream.js +1 -1
  75. package/lib/cjs/__/env-ci/__/execa/lib/verbose.js +2 -2
  76. package/lib/cjs/__/env-ci/__/execa/lib/verbose.js.map +1 -1
  77. package/lib/cjs/__/env-ci/__/npm-run-path/index.js +3 -3
  78. package/lib/cjs/__/env-ci/__/npm-run-path/index.js.map +1 -1
  79. package/lib/cjs/__/fast-content-type-parse/index.js +182 -0
  80. package/lib/cjs/__/fast-content-type-parse/index.js.map +1 -0
  81. package/lib/cjs/__/java-properties/dist-node/index.js +1 -1
  82. package/lib/cjs/__/path-key/index.js +1 -1
  83. package/lib/cjs/__/tunnel/index.js +16 -0
  84. package/lib/cjs/__/tunnel/index.js.map +1 -0
  85. package/lib/cjs/__/tunnel/lib/tunnel.js +289 -0
  86. package/lib/cjs/__/tunnel/lib/tunnel.js.map +1 -0
  87. package/lib/cjs/__/undici/index.js +212 -0
  88. package/lib/cjs/__/undici/index.js.map +1 -0
  89. package/lib/cjs/__/undici/lib/agent.js +169 -0
  90. package/lib/cjs/__/undici/lib/agent.js.map +1 -0
  91. package/lib/cjs/__/undici/lib/api/abort-signal.js +70 -0
  92. package/lib/cjs/__/undici/lib/api/abort-signal.js.map +1 -0
  93. package/lib/cjs/__/undici/lib/api/api-connect.js +125 -0
  94. package/lib/cjs/__/undici/lib/api/api-connect.js.map +1 -0
  95. package/lib/cjs/__/undici/lib/api/api-pipeline.js +274 -0
  96. package/lib/cjs/__/undici/lib/api/api-pipeline.js.map +1 -0
  97. package/lib/cjs/__/undici/lib/api/api-request.js +203 -0
  98. package/lib/cjs/__/undici/lib/api/api-request.js.map +1 -0
  99. package/lib/cjs/__/undici/lib/api/api-stream.js +244 -0
  100. package/lib/cjs/__/undici/lib/api/api-stream.js.map +1 -0
  101. package/lib/cjs/__/undici/lib/api/api-upgrade.js +128 -0
  102. package/lib/cjs/__/undici/lib/api/api-upgrade.js.map +1 -0
  103. package/lib/cjs/__/undici/lib/api/index.js +25 -0
  104. package/lib/cjs/__/undici/lib/api/index.js.map +1 -0
  105. package/lib/cjs/__/undici/lib/api/readable.js +342 -0
  106. package/lib/cjs/__/undici/lib/api/readable.js.map +1 -0
  107. package/lib/cjs/__/undici/lib/api/util.js +67 -0
  108. package/lib/cjs/__/undici/lib/api/util.js.map +1 -0
  109. package/lib/cjs/__/undici/lib/balanced-pool.js +208 -0
  110. package/lib/cjs/__/undici/lib/balanced-pool.js.map +1 -0
  111. package/lib/cjs/__/undici/lib/cache/cache.js +867 -0
  112. package/lib/cjs/__/undici/lib/cache/cache.js.map +1 -0
  113. package/lib/cjs/__/undici/lib/cache/cachestorage.js +161 -0
  114. package/lib/cjs/__/undici/lib/cache/cachestorage.js.map +1 -0
  115. package/lib/cjs/__/undici/lib/cache/symbols.js +19 -0
  116. package/lib/cjs/__/undici/lib/cache/symbols.js.map +1 -0
  117. package/lib/cjs/__/undici/lib/cache/util.js +69 -0
  118. package/lib/cjs/__/undici/lib/cache/util.js.map +1 -0
  119. package/lib/cjs/__/undici/lib/client.js +2314 -0
  120. package/lib/cjs/__/undici/lib/client.js.map +1 -0
  121. package/lib/cjs/__/undici/lib/compat/dispatcher-weakref.js +63 -0
  122. package/lib/cjs/__/undici/lib/compat/dispatcher-weakref.js.map +1 -0
  123. package/lib/cjs/__/undici/lib/cookies/constants.js +24 -0
  124. package/lib/cjs/__/undici/lib/cookies/constants.js.map +1 -0
  125. package/lib/cjs/__/undici/lib/cookies/index.js +200 -0
  126. package/lib/cjs/__/undici/lib/cookies/index.js.map +1 -0
  127. package/lib/cjs/__/undici/lib/cookies/parse.js +338 -0
  128. package/lib/cjs/__/undici/lib/cookies/parse.js.map +1 -0
  129. package/lib/cjs/__/undici/lib/cookies/util.js +286 -0
  130. package/lib/cjs/__/undici/lib/cookies/util.js.map +1 -0
  131. package/lib/cjs/__/undici/lib/core/connect.js +214 -0
  132. package/lib/cjs/__/undici/lib/core/connect.js.map +1 -0
  133. package/lib/cjs/__/undici/lib/core/constants.js +130 -0
  134. package/lib/cjs/__/undici/lib/core/constants.js.map +1 -0
  135. package/lib/cjs/__/undici/lib/core/errors.js +242 -0
  136. package/lib/cjs/__/undici/lib/core/errors.js.map +1 -0
  137. package/lib/cjs/__/undici/lib/core/request.js +521 -0
  138. package/lib/cjs/__/undici/lib/core/request.js.map +1 -0
  139. package/lib/cjs/__/undici/lib/core/symbols.js +76 -0
  140. package/lib/cjs/__/undici/lib/core/symbols.js.map +1 -0
  141. package/lib/cjs/__/undici/lib/core/util.js +557 -0
  142. package/lib/cjs/__/undici/lib/core/util.js.map +1 -0
  143. package/lib/cjs/__/undici/lib/dispatcher-base.js +208 -0
  144. package/lib/cjs/__/undici/lib/dispatcher-base.js.map +1 -0
  145. package/lib/cjs/__/undici/lib/dispatcher.js +37 -0
  146. package/lib/cjs/__/undici/lib/dispatcher.js.map +1 -0
  147. package/lib/cjs/__/undici/lib/fetch/body.js +647 -0
  148. package/lib/cjs/__/undici/lib/fetch/body.js.map +1 -0
  149. package/lib/cjs/__/undici/lib/fetch/constants.js +169 -0
  150. package/lib/cjs/__/undici/lib/fetch/constants.js.map +1 -0
  151. package/lib/cjs/__/undici/lib/fetch/dataURL.js +649 -0
  152. package/lib/cjs/__/undici/lib/fetch/dataURL.js.map +1 -0
  153. package/lib/cjs/__/undici/lib/fetch/file.js +369 -0
  154. package/lib/cjs/__/undici/lib/fetch/file.js.map +1 -0
  155. package/lib/cjs/__/undici/lib/fetch/formdata.js +287 -0
  156. package/lib/cjs/__/undici/lib/fetch/formdata.js.map +1 -0
  157. package/lib/cjs/__/undici/lib/fetch/global.js +52 -0
  158. package/lib/cjs/__/undici/lib/fetch/global.js.map +1 -0
  159. package/lib/cjs/__/undici/lib/fetch/headers.js +609 -0
  160. package/lib/cjs/__/undici/lib/fetch/headers.js.map +1 -0
  161. package/lib/cjs/__/undici/lib/fetch/index.js +2114 -0
  162. package/lib/cjs/__/undici/lib/fetch/index.js.map +1 -0
  163. package/lib/cjs/__/undici/lib/fetch/request.js +979 -0
  164. package/lib/cjs/__/undici/lib/fetch/request.js.map +1 -0
  165. package/lib/cjs/__/undici/lib/fetch/response.js +604 -0
  166. package/lib/cjs/__/undici/lib/fetch/response.js.map +1 -0
  167. package/lib/cjs/__/undici/lib/fetch/symbols.js +22 -0
  168. package/lib/cjs/__/undici/lib/fetch/symbols.js.map +1 -0
  169. package/lib/cjs/__/undici/lib/fetch/util.js +1170 -0
  170. package/lib/cjs/__/undici/lib/fetch/util.js.map +1 -0
  171. package/lib/cjs/__/undici/lib/fetch/webidl.js +665 -0
  172. package/lib/cjs/__/undici/lib/fetch/webidl.js.map +1 -0
  173. package/lib/cjs/__/undici/lib/fileapi/encoding.js +302 -0
  174. package/lib/cjs/__/undici/lib/fileapi/encoding.js.map +1 -0
  175. package/lib/cjs/__/undici/lib/fileapi/filereader.js +361 -0
  176. package/lib/cjs/__/undici/lib/fileapi/filereader.js.map +1 -0
  177. package/lib/cjs/__/undici/lib/fileapi/progressevent.js +92 -0
  178. package/lib/cjs/__/undici/lib/fileapi/progressevent.js.map +1 -0
  179. package/lib/cjs/__/undici/lib/fileapi/symbols.js +22 -0
  180. package/lib/cjs/__/undici/lib/fileapi/symbols.js.map +1 -0
  181. package/lib/cjs/__/undici/lib/fileapi/util.js +419 -0
  182. package/lib/cjs/__/undici/lib/fileapi/util.js.map +1 -0
  183. package/lib/cjs/__/undici/lib/global.js +47 -0
  184. package/lib/cjs/__/undici/lib/global.js.map +1 -0
  185. package/lib/cjs/__/undici/lib/handler/DecoratorHandler.js +47 -0
  186. package/lib/cjs/__/undici/lib/handler/DecoratorHandler.js.map +1 -0
  187. package/lib/cjs/__/undici/lib/handler/RedirectHandler.js +226 -0
  188. package/lib/cjs/__/undici/lib/handler/RedirectHandler.js.map +1 -0
  189. package/lib/cjs/__/undici/lib/handler/RetryHandler.js +358 -0
  190. package/lib/cjs/__/undici/lib/handler/RetryHandler.js.map +1 -0
  191. package/lib/cjs/__/undici/lib/interceptor/redirectInterceptor.js +35 -0
  192. package/lib/cjs/__/undici/lib/interceptor/redirectInterceptor.js.map +1 -0
  193. package/lib/cjs/__/undici/lib/llhttp/constants.js +288 -0
  194. package/lib/cjs/__/undici/lib/llhttp/constants.js.map +1 -0
  195. package/lib/cjs/__/undici/lib/llhttp/llhttp-wasm.js +14 -0
  196. package/lib/cjs/__/undici/lib/llhttp/llhttp-wasm.js.map +1 -0
  197. package/lib/cjs/__/undici/lib/llhttp/llhttp_simd-wasm.js +14 -0
  198. package/lib/cjs/__/undici/lib/llhttp/llhttp_simd-wasm.js.map +1 -0
  199. package/lib/cjs/__/undici/lib/llhttp/utils.js +28 -0
  200. package/lib/cjs/__/undici/lib/llhttp/utils.js.map +1 -0
  201. package/lib/cjs/__/undici/lib/mock/mock-agent.js +194 -0
  202. package/lib/cjs/__/undici/lib/mock/mock-agent.js.map +1 -0
  203. package/lib/cjs/__/undici/lib/mock/mock-client.js +83 -0
  204. package/lib/cjs/__/undici/lib/mock/mock-client.js.map +1 -0
  205. package/lib/cjs/__/undici/lib/mock/mock-errors.js +31 -0
  206. package/lib/cjs/__/undici/lib/mock/mock-errors.js.map +1 -0
  207. package/lib/cjs/__/undici/lib/mock/mock-interceptor.js +223 -0
  208. package/lib/cjs/__/undici/lib/mock/mock-interceptor.js.map +1 -0
  209. package/lib/cjs/__/undici/lib/mock/mock-pool.js +83 -0
  210. package/lib/cjs/__/undici/lib/mock/mock-pool.js.map +1 -0
  211. package/lib/cjs/__/undici/lib/mock/mock-symbols.js +35 -0
  212. package/lib/cjs/__/undici/lib/mock/mock-symbols.js.map +1 -0
  213. package/lib/cjs/__/undici/lib/mock/mock-utils.js +374 -0
  214. package/lib/cjs/__/undici/lib/mock/mock-utils.js.map +1 -0
  215. package/lib/cjs/__/undici/lib/mock/pending-interceptors-formatter.js +60 -0
  216. package/lib/cjs/__/undici/lib/mock/pending-interceptors-formatter.js.map +1 -0
  217. package/lib/cjs/__/undici/lib/mock/pluralizer.js +41 -0
  218. package/lib/cjs/__/undici/lib/mock/pluralizer.js.map +1 -0
  219. package/lib/cjs/__/undici/lib/node/fixed-queue.js +129 -0
  220. package/lib/cjs/__/undici/lib/node/fixed-queue.js.map +1 -0
  221. package/lib/cjs/__/undici/lib/pool-base.js +211 -0
  222. package/lib/cjs/__/undici/lib/pool-base.js.map +1 -0
  223. package/lib/cjs/__/undici/lib/pool-stats.js +49 -0
  224. package/lib/cjs/__/undici/lib/pool-stats.js.map +1 -0
  225. package/lib/cjs/__/undici/lib/pool.js +127 -0
  226. package/lib/cjs/__/undici/lib/pool.js.map +1 -0
  227. package/lib/cjs/__/undici/lib/proxy-agent.js +213 -0
  228. package/lib/cjs/__/undici/lib/proxy-agent.js.map +1 -0
  229. package/lib/cjs/__/undici/lib/timers.js +109 -0
  230. package/lib/cjs/__/undici/lib/timers.js.map +1 -0
  231. package/lib/cjs/__/undici/lib/websocket/connection.js +318 -0
  232. package/lib/cjs/__/undici/lib/websocket/connection.js.map +1 -0
  233. package/lib/cjs/__/undici/lib/websocket/constants.js +63 -0
  234. package/lib/cjs/__/undici/lib/websocket/constants.js.map +1 -0
  235. package/lib/cjs/__/undici/lib/websocket/events.js +323 -0
  236. package/lib/cjs/__/undici/lib/websocket/events.js.map +1 -0
  237. package/lib/cjs/__/undici/lib/websocket/frame.js +87 -0
  238. package/lib/cjs/__/undici/lib/websocket/frame.js.map +1 -0
  239. package/lib/cjs/__/undici/lib/websocket/receiver.js +368 -0
  240. package/lib/cjs/__/undici/lib/websocket/receiver.js.map +1 -0
  241. package/lib/cjs/__/undici/lib/websocket/symbols.js +24 -0
  242. package/lib/cjs/__/undici/lib/websocket/symbols.js.map +1 -0
  243. package/lib/cjs/__/undici/lib/websocket/util.js +216 -0
  244. package/lib/cjs/__/undici/lib/websocket/util.js.map +1 -0
  245. package/lib/cjs/__/undici/lib/websocket/websocket.js +668 -0
  246. package/lib/cjs/__/undici/lib/websocket/websocket.js.map +1 -0
  247. package/lib/cjs/_virtual/_commonjsHelpers.js +30 -0
  248. package/lib/cjs/_virtual/_commonjsHelpers.js.map +1 -1
  249. package/lib/cjs/_virtual/api-request.js +6 -0
  250. package/lib/cjs/_virtual/api-request.js.map +1 -0
  251. package/lib/cjs/_virtual/constants.js +6 -0
  252. package/lib/cjs/_virtual/constants.js.map +1 -0
  253. package/lib/cjs/_virtual/context.js +6 -0
  254. package/lib/cjs/_virtual/context.js.map +1 -0
  255. package/lib/cjs/_virtual/github.js +8 -0
  256. package/lib/cjs/_virtual/github.js.map +1 -0
  257. package/lib/cjs/_virtual/github2.js +6 -0
  258. package/lib/cjs/_virtual/github2.js.map +1 -0
  259. package/lib/cjs/_virtual/index10.js +6 -0
  260. package/lib/cjs/_virtual/index10.js.map +1 -0
  261. package/lib/cjs/_virtual/index11.js +6 -0
  262. package/lib/cjs/_virtual/index11.js.map +1 -0
  263. package/lib/cjs/_virtual/index12.js +6 -0
  264. package/lib/cjs/_virtual/index12.js.map +1 -0
  265. package/lib/cjs/_virtual/index13.js +6 -0
  266. package/lib/cjs/_virtual/index13.js.map +1 -0
  267. package/lib/cjs/_virtual/index14.js +6 -0
  268. package/lib/cjs/_virtual/index14.js.map +1 -0
  269. package/lib/cjs/_virtual/index2.js +5 -2
  270. package/lib/cjs/_virtual/index2.js.map +1 -1
  271. package/lib/cjs/_virtual/index3.js +3 -4
  272. package/lib/cjs/_virtual/index3.js.map +1 -1
  273. package/lib/cjs/_virtual/index4.js +5 -2
  274. package/lib/cjs/_virtual/index4.js.map +1 -1
  275. package/lib/cjs/_virtual/index5.js +2 -2
  276. package/lib/cjs/_virtual/index6.js +6 -2
  277. package/lib/cjs/_virtual/index6.js.map +1 -1
  278. package/lib/cjs/_virtual/index7.js +6 -0
  279. package/lib/cjs/_virtual/index7.js.map +1 -0
  280. package/lib/cjs/_virtual/index8.js +6 -0
  281. package/lib/cjs/_virtual/index8.js.map +1 -0
  282. package/lib/cjs/_virtual/index9.js +8 -0
  283. package/lib/cjs/_virtual/index9.js.map +1 -0
  284. package/lib/cjs/_virtual/main.js +6 -0
  285. package/lib/cjs/_virtual/main.js.map +1 -0
  286. package/lib/cjs/_virtual/mock-interceptor.js +6 -0
  287. package/lib/cjs/_virtual/mock-interceptor.js.map +1 -0
  288. package/lib/cjs/_virtual/proxy.js +6 -0
  289. package/lib/cjs/_virtual/proxy.js.map +1 -0
  290. package/lib/cjs/_virtual/tunnel.js +6 -0
  291. package/lib/cjs/_virtual/tunnel.js.map +1 -0
  292. package/lib/cjs/_virtual/utils.js +6 -0
  293. package/lib/cjs/_virtual/utils.js.map +1 -0
  294. package/lib/cjs/_virtual/utils2.js +6 -0
  295. package/lib/cjs/_virtual/utils2.js.map +1 -0
  296. package/lib/cjs/_virtual/utils3.js +6 -0
  297. package/lib/cjs/_virtual/utils3.js.map +1 -0
  298. package/lib/cjs/artifacts/filter-artifacts.js.map +1 -1
  299. package/lib/cjs/env/ci-env.js +6 -1
  300. package/lib/cjs/env/ci-env.js.map +1 -1
  301. package/lib/cjs/env/load.js +1 -1
  302. package/lib/cjs/env/load.js.map +1 -1
  303. package/lib/cjs/env/service/github.js +3 -22
  304. package/lib/cjs/env/service/github.js.map +1 -1
  305. package/lib/cjs/ingest/ingest.js +4 -4
  306. package/lib/cjs/ingest/ingest.js.map +1 -1
  307. package/lib/cjs/locales/en.js.map +1 -1
  308. package/lib/esm/__/@actions/github/__/@octokit/auth-token/dist-bundle/index.js +55 -0
  309. package/lib/esm/__/@actions/github/__/@octokit/auth-token/dist-bundle/index.js.map +1 -0
  310. package/lib/esm/__/@actions/github/__/@octokit/core/dist-src/index.js +142 -0
  311. package/lib/esm/__/@actions/github/__/@octokit/core/dist-src/index.js.map +1 -0
  312. package/lib/esm/__/@actions/github/__/@octokit/core/dist-src/version.js +4 -0
  313. package/lib/esm/__/@actions/github/__/@octokit/core/dist-src/version.js.map +1 -0
  314. package/lib/esm/__/@actions/github/__/@octokit/endpoint/dist-bundle/index.js +347 -0
  315. package/lib/esm/__/@actions/github/__/@octokit/endpoint/dist-bundle/index.js.map +1 -0
  316. package/lib/esm/__/@actions/github/__/@octokit/graphql/dist-bundle/index.js +122 -0
  317. package/lib/esm/__/@actions/github/__/@octokit/graphql/dist-bundle/index.js.map +1 -0
  318. package/lib/esm/__/@actions/github/__/@octokit/plugin-paginate-rest/dist-bundle/index.js +412 -0
  319. package/lib/esm/__/@actions/github/__/@octokit/plugin-paginate-rest/dist-bundle/index.js.map +1 -0
  320. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +126 -0
  321. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js.map +1 -0
  322. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +2293 -0
  323. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js.map +1 -0
  324. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +21 -0
  325. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/index.js.map +1 -0
  326. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +4 -0
  327. package/lib/esm/__/@actions/github/__/@octokit/plugin-rest-endpoint-methods/dist-src/version.js.map +1 -0
  328. package/lib/esm/__/@actions/github/__/@octokit/request/dist-bundle/index.js +197 -0
  329. package/lib/esm/__/@actions/github/__/@octokit/request/dist-bundle/index.js.map +1 -0
  330. package/lib/esm/__/@actions/github/__/@octokit/request-error/dist-src/index.js +41 -0
  331. package/lib/esm/__/@actions/github/__/@octokit/request-error/dist-src/index.js.map +1 -0
  332. package/lib/esm/__/@actions/github/__/before-after-hook/index.js +39 -0
  333. package/lib/esm/__/@actions/github/__/before-after-hook/index.js.map +1 -0
  334. package/lib/esm/__/@actions/github/__/before-after-hook/lib/add.js +49 -0
  335. package/lib/esm/__/@actions/github/__/before-after-hook/lib/add.js.map +1 -0
  336. package/lib/esm/__/@actions/github/__/before-after-hook/lib/register.js +30 -0
  337. package/lib/esm/__/@actions/github/__/before-after-hook/lib/register.js.map +1 -0
  338. package/lib/esm/__/@actions/github/__/before-after-hook/lib/remove.js +22 -0
  339. package/lib/esm/__/@actions/github/__/before-after-hook/lib/remove.js.map +1 -0
  340. package/lib/esm/__/@actions/github/__/universal-user-agent/index.js +16 -0
  341. package/lib/esm/__/@actions/github/__/universal-user-agent/index.js.map +1 -0
  342. package/lib/esm/__/@actions/github/lib/context.js +69 -0
  343. package/lib/esm/__/@actions/github/lib/context.js.map +1 -0
  344. package/lib/esm/__/@actions/github/lib/github.js +64 -0
  345. package/lib/esm/__/@actions/github/lib/github.js.map +1 -0
  346. package/lib/esm/__/@actions/github/lib/internal/utils.js +92 -0
  347. package/lib/esm/__/@actions/github/lib/internal/utils.js.map +1 -0
  348. package/lib/esm/__/@actions/github/lib/utils.js +87 -0
  349. package/lib/esm/__/@actions/github/lib/utils.js.map +1 -0
  350. package/lib/esm/__/@actions/http-client/lib/index.js +753 -0
  351. package/lib/esm/__/@actions/http-client/lib/index.js.map +1 -0
  352. package/lib/esm/__/@actions/http-client/lib/proxy.js +105 -0
  353. package/lib/esm/__/@actions/http-client/lib/proxy.js.map +1 -0
  354. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/Dicer.js +229 -0
  355. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/Dicer.js.map +1 -0
  356. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/HeaderParser.js +115 -0
  357. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/HeaderParser.js.map +1 -0
  358. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/PartStream.js +26 -0
  359. package/lib/esm/__/@fastify/busboy/deps/dicer/lib/PartStream.js.map +1 -0
  360. package/lib/esm/__/@fastify/busboy/deps/streamsearch/sbmh.js +241 -0
  361. package/lib/esm/__/@fastify/busboy/deps/streamsearch/sbmh.js.map +1 -0
  362. package/lib/esm/__/@fastify/busboy/lib/main.js +102 -0
  363. package/lib/esm/__/@fastify/busboy/lib/main.js.map +1 -0
  364. package/lib/esm/__/@fastify/busboy/lib/types/multipart.js +324 -0
  365. package/lib/esm/__/@fastify/busboy/lib/types/multipart.js.map +1 -0
  366. package/lib/esm/__/@fastify/busboy/lib/types/urlencoded.js +204 -0
  367. package/lib/esm/__/@fastify/busboy/lib/types/urlencoded.js.map +1 -0
  368. package/lib/esm/__/@fastify/busboy/lib/utils/Decoder.js +64 -0
  369. package/lib/esm/__/@fastify/busboy/lib/utils/Decoder.js.map +1 -0
  370. package/lib/esm/__/@fastify/busboy/lib/utils/basename.js +24 -0
  371. package/lib/esm/__/@fastify/busboy/lib/utils/basename.js.map +1 -0
  372. package/lib/esm/__/@fastify/busboy/lib/utils/decodeText.js +124 -0
  373. package/lib/esm/__/@fastify/busboy/lib/utils/decodeText.js.map +1 -0
  374. package/lib/esm/__/@fastify/busboy/lib/utils/getLimit.js +26 -0
  375. package/lib/esm/__/@fastify/busboy/lib/utils/getLimit.js.map +1 -0
  376. package/lib/esm/__/@fastify/busboy/lib/utils/parseParams.js +209 -0
  377. package/lib/esm/__/@fastify/busboy/lib/utils/parseParams.js.map +1 -0
  378. package/lib/esm/__/cross-spawn/index.js +1 -1
  379. package/lib/esm/__/env-ci/__/execa/index.js +1 -1
  380. package/lib/esm/__/env-ci/__/execa/lib/stream.js +1 -1
  381. package/lib/esm/__/fast-content-type-parse/index.js +180 -0
  382. package/lib/esm/__/fast-content-type-parse/index.js.map +1 -0
  383. package/lib/esm/__/java-properties/dist-node/index.js +1 -1
  384. package/lib/esm/__/path-key/index.js +1 -1
  385. package/lib/esm/__/tunnel/index.js +14 -0
  386. package/lib/esm/__/tunnel/index.js.map +1 -0
  387. package/lib/esm/__/tunnel/lib/tunnel.js +279 -0
  388. package/lib/esm/__/tunnel/lib/tunnel.js.map +1 -0
  389. package/lib/esm/__/undici/index.js +210 -0
  390. package/lib/esm/__/undici/index.js.map +1 -0
  391. package/lib/esm/__/undici/lib/agent.js +167 -0
  392. package/lib/esm/__/undici/lib/agent.js.map +1 -0
  393. package/lib/esm/__/undici/lib/api/abort-signal.js +68 -0
  394. package/lib/esm/__/undici/lib/api/abort-signal.js.map +1 -0
  395. package/lib/esm/__/undici/lib/api/api-connect.js +119 -0
  396. package/lib/esm/__/undici/lib/api/api-connect.js.map +1 -0
  397. package/lib/esm/__/undici/lib/api/api-pipeline.js +266 -0
  398. package/lib/esm/__/undici/lib/api/api-pipeline.js.map +1 -0
  399. package/lib/esm/__/undici/lib/api/api-request.js +197 -0
  400. package/lib/esm/__/undici/lib/api/api-request.js.map +1 -0
  401. package/lib/esm/__/undici/lib/api/api-stream.js +237 -0
  402. package/lib/esm/__/undici/lib/api/api-stream.js.map +1 -0
  403. package/lib/esm/__/undici/lib/api/api-upgrade.js +121 -0
  404. package/lib/esm/__/undici/lib/api/api-upgrade.js.map +1 -0
  405. package/lib/esm/__/undici/lib/api/index.js +23 -0
  406. package/lib/esm/__/undici/lib/api/index.js.map +1 -0
  407. package/lib/esm/__/undici/lib/api/readable.js +335 -0
  408. package/lib/esm/__/undici/lib/api/readable.js.map +1 -0
  409. package/lib/esm/__/undici/lib/api/util.js +61 -0
  410. package/lib/esm/__/undici/lib/api/util.js.map +1 -0
  411. package/lib/esm/__/undici/lib/balanced-pool.js +206 -0
  412. package/lib/esm/__/undici/lib/balanced-pool.js.map +1 -0
  413. package/lib/esm/__/undici/lib/cache/cache.js +861 -0
  414. package/lib/esm/__/undici/lib/cache/cache.js.map +1 -0
  415. package/lib/esm/__/undici/lib/cache/cachestorage.js +159 -0
  416. package/lib/esm/__/undici/lib/cache/cachestorage.js.map +1 -0
  417. package/lib/esm/__/undici/lib/cache/symbols.js +17 -0
  418. package/lib/esm/__/undici/lib/cache/symbols.js.map +1 -0
  419. package/lib/esm/__/undici/lib/cache/util.js +63 -0
  420. package/lib/esm/__/undici/lib/cache/util.js.map +1 -0
  421. package/lib/esm/__/undici/lib/client.js +2305 -0
  422. package/lib/esm/__/undici/lib/client.js.map +1 -0
  423. package/lib/esm/__/undici/lib/compat/dispatcher-weakref.js +61 -0
  424. package/lib/esm/__/undici/lib/compat/dispatcher-weakref.js.map +1 -0
  425. package/lib/esm/__/undici/lib/cookies/constants.js +22 -0
  426. package/lib/esm/__/undici/lib/cookies/constants.js.map +1 -0
  427. package/lib/esm/__/undici/lib/cookies/index.js +198 -0
  428. package/lib/esm/__/undici/lib/cookies/index.js.map +1 -0
  429. package/lib/esm/__/undici/lib/cookies/parse.js +332 -0
  430. package/lib/esm/__/undici/lib/cookies/parse.js.map +1 -0
  431. package/lib/esm/__/undici/lib/cookies/util.js +284 -0
  432. package/lib/esm/__/undici/lib/cookies/util.js.map +1 -0
  433. package/lib/esm/__/undici/lib/core/connect.js +206 -0
  434. package/lib/esm/__/undici/lib/core/connect.js.map +1 -0
  435. package/lib/esm/__/undici/lib/core/constants.js +128 -0
  436. package/lib/esm/__/undici/lib/core/constants.js.map +1 -0
  437. package/lib/esm/__/undici/lib/core/errors.js +240 -0
  438. package/lib/esm/__/undici/lib/core/errors.js.map +1 -0
  439. package/lib/esm/__/undici/lib/core/request.js +515 -0
  440. package/lib/esm/__/undici/lib/core/request.js.map +1 -0
  441. package/lib/esm/__/undici/lib/core/symbols.js +74 -0
  442. package/lib/esm/__/undici/lib/core/symbols.js.map +1 -0
  443. package/lib/esm/__/undici/lib/core/util.js +544 -0
  444. package/lib/esm/__/undici/lib/core/util.js.map +1 -0
  445. package/lib/esm/__/undici/lib/dispatcher-base.js +206 -0
  446. package/lib/esm/__/undici/lib/dispatcher-base.js.map +1 -0
  447. package/lib/esm/__/undici/lib/dispatcher.js +31 -0
  448. package/lib/esm/__/undici/lib/dispatcher.js.map +1 -0
  449. package/lib/esm/__/undici/lib/fetch/body.js +638 -0
  450. package/lib/esm/__/undici/lib/fetch/body.js.map +1 -0
  451. package/lib/esm/__/undici/lib/fetch/constants.js +163 -0
  452. package/lib/esm/__/undici/lib/fetch/constants.js.map +1 -0
  453. package/lib/esm/__/undici/lib/fetch/dataURL.js +642 -0
  454. package/lib/esm/__/undici/lib/fetch/dataURL.js.map +1 -0
  455. package/lib/esm/__/undici/lib/fetch/file.js +362 -0
  456. package/lib/esm/__/undici/lib/fetch/file.js.map +1 -0
  457. package/lib/esm/__/undici/lib/fetch/formdata.js +281 -0
  458. package/lib/esm/__/undici/lib/fetch/formdata.js.map +1 -0
  459. package/lib/esm/__/undici/lib/fetch/global.js +50 -0
  460. package/lib/esm/__/undici/lib/fetch/global.js.map +1 -0
  461. package/lib/esm/__/undici/lib/fetch/headers.js +602 -0
  462. package/lib/esm/__/undici/lib/fetch/headers.js.map +1 -0
  463. package/lib/esm/__/undici/lib/fetch/index.js +2102 -0
  464. package/lib/esm/__/undici/lib/fetch/index.js.map +1 -0
  465. package/lib/esm/__/undici/lib/fetch/request.js +971 -0
  466. package/lib/esm/__/undici/lib/fetch/request.js.map +1 -0
  467. package/lib/esm/__/undici/lib/fetch/response.js +596 -0
  468. package/lib/esm/__/undici/lib/fetch/response.js.map +1 -0
  469. package/lib/esm/__/undici/lib/fetch/symbols.js +20 -0
  470. package/lib/esm/__/undici/lib/fetch/symbols.js.map +1 -0
  471. package/lib/esm/__/undici/lib/fetch/util.js +1161 -0
  472. package/lib/esm/__/undici/lib/fetch/util.js.map +1 -0
  473. package/lib/esm/__/undici/lib/fetch/webidl.js +659 -0
  474. package/lib/esm/__/undici/lib/fetch/webidl.js.map +1 -0
  475. package/lib/esm/__/undici/lib/fileapi/encoding.js +300 -0
  476. package/lib/esm/__/undici/lib/fileapi/encoding.js.map +1 -0
  477. package/lib/esm/__/undici/lib/fileapi/filereader.js +359 -0
  478. package/lib/esm/__/undici/lib/fileapi/filereader.js.map +1 -0
  479. package/lib/esm/__/undici/lib/fileapi/progressevent.js +90 -0
  480. package/lib/esm/__/undici/lib/fileapi/progressevent.js.map +1 -0
  481. package/lib/esm/__/undici/lib/fileapi/symbols.js +20 -0
  482. package/lib/esm/__/undici/lib/fileapi/symbols.js.map +1 -0
  483. package/lib/esm/__/undici/lib/fileapi/util.js +411 -0
  484. package/lib/esm/__/undici/lib/fileapi/util.js.map +1 -0
  485. package/lib/esm/__/undici/lib/global.js +45 -0
  486. package/lib/esm/__/undici/lib/global.js.map +1 -0
  487. package/lib/esm/__/undici/lib/handler/DecoratorHandler.js +45 -0
  488. package/lib/esm/__/undici/lib/handler/DecoratorHandler.js.map +1 -0
  489. package/lib/esm/__/undici/lib/handler/RedirectHandler.js +219 -0
  490. package/lib/esm/__/undici/lib/handler/RedirectHandler.js.map +1 -0
  491. package/lib/esm/__/undici/lib/handler/RetryHandler.js +352 -0
  492. package/lib/esm/__/undici/lib/handler/RetryHandler.js.map +1 -0
  493. package/lib/esm/__/undici/lib/interceptor/redirectInterceptor.js +33 -0
  494. package/lib/esm/__/undici/lib/interceptor/redirectInterceptor.js.map +1 -0
  495. package/lib/esm/__/undici/lib/llhttp/constants.js +286 -0
  496. package/lib/esm/__/undici/lib/llhttp/constants.js.map +1 -0
  497. package/lib/esm/__/undici/lib/llhttp/llhttp-wasm.js +12 -0
  498. package/lib/esm/__/undici/lib/llhttp/llhttp-wasm.js.map +1 -0
  499. package/lib/esm/__/undici/lib/llhttp/llhttp_simd-wasm.js +12 -0
  500. package/lib/esm/__/undici/lib/llhttp/llhttp_simd-wasm.js.map +1 -0
  501. package/lib/esm/__/undici/lib/llhttp/utils.js +26 -0
  502. package/lib/esm/__/undici/lib/llhttp/utils.js.map +1 -0
  503. package/lib/esm/__/undici/lib/mock/mock-agent.js +192 -0
  504. package/lib/esm/__/undici/lib/mock/mock-agent.js.map +1 -0
  505. package/lib/esm/__/undici/lib/mock/mock-client.js +77 -0
  506. package/lib/esm/__/undici/lib/mock/mock-client.js.map +1 -0
  507. package/lib/esm/__/undici/lib/mock/mock-errors.js +29 -0
  508. package/lib/esm/__/undici/lib/mock/mock-errors.js.map +1 -0
  509. package/lib/esm/__/undici/lib/mock/mock-interceptor.js +221 -0
  510. package/lib/esm/__/undici/lib/mock/mock-interceptor.js.map +1 -0
  511. package/lib/esm/__/undici/lib/mock/mock-pool.js +77 -0
  512. package/lib/esm/__/undici/lib/mock/mock-pool.js.map +1 -0
  513. package/lib/esm/__/undici/lib/mock/mock-symbols.js +33 -0
  514. package/lib/esm/__/undici/lib/mock/mock-symbols.js.map +1 -0
  515. package/lib/esm/__/undici/lib/mock/mock-utils.js +367 -0
  516. package/lib/esm/__/undici/lib/mock/mock-utils.js.map +1 -0
  517. package/lib/esm/__/undici/lib/mock/pending-interceptors-formatter.js +53 -0
  518. package/lib/esm/__/undici/lib/mock/pending-interceptors-formatter.js.map +1 -0
  519. package/lib/esm/__/undici/lib/mock/pluralizer.js +39 -0
  520. package/lib/esm/__/undici/lib/mock/pluralizer.js.map +1 -0
  521. package/lib/esm/__/undici/lib/node/fixed-queue.js +127 -0
  522. package/lib/esm/__/undici/lib/node/fixed-queue.js.map +1 -0
  523. package/lib/esm/__/undici/lib/pool-base.js +209 -0
  524. package/lib/esm/__/undici/lib/pool-base.js.map +1 -0
  525. package/lib/esm/__/undici/lib/pool-stats.js +47 -0
  526. package/lib/esm/__/undici/lib/pool-stats.js.map +1 -0
  527. package/lib/esm/__/undici/lib/pool.js +125 -0
  528. package/lib/esm/__/undici/lib/pool.js.map +1 -0
  529. package/lib/esm/__/undici/lib/proxy-agent.js +207 -0
  530. package/lib/esm/__/undici/lib/proxy-agent.js.map +1 -0
  531. package/lib/esm/__/undici/lib/timers.js +107 -0
  532. package/lib/esm/__/undici/lib/timers.js.map +1 -0
  533. package/lib/esm/__/undici/lib/websocket/connection.js +312 -0
  534. package/lib/esm/__/undici/lib/websocket/connection.js.map +1 -0
  535. package/lib/esm/__/undici/lib/websocket/constants.js +61 -0
  536. package/lib/esm/__/undici/lib/websocket/constants.js.map +1 -0
  537. package/lib/esm/__/undici/lib/websocket/events.js +317 -0
  538. package/lib/esm/__/undici/lib/websocket/events.js.map +1 -0
  539. package/lib/esm/__/undici/lib/websocket/frame.js +85 -0
  540. package/lib/esm/__/undici/lib/websocket/frame.js.map +1 -0
  541. package/lib/esm/__/undici/lib/websocket/receiver.js +361 -0
  542. package/lib/esm/__/undici/lib/websocket/receiver.js.map +1 -0
  543. package/lib/esm/__/undici/lib/websocket/symbols.js +22 -0
  544. package/lib/esm/__/undici/lib/websocket/symbols.js.map +1 -0
  545. package/lib/esm/__/undici/lib/websocket/util.js +214 -0
  546. package/lib/esm/__/undici/lib/websocket/util.js.map +1 -0
  547. package/lib/esm/__/undici/lib/websocket/websocket.js +662 -0
  548. package/lib/esm/__/undici/lib/websocket/websocket.js.map +1 -0
  549. package/lib/esm/_virtual/_commonjsHelpers.js +30 -1
  550. package/lib/esm/_virtual/_commonjsHelpers.js.map +1 -1
  551. package/lib/esm/_virtual/api-request.js +4 -0
  552. package/lib/esm/_virtual/api-request.js.map +1 -0
  553. package/lib/esm/_virtual/constants.js +4 -0
  554. package/lib/esm/_virtual/constants.js.map +1 -0
  555. package/lib/esm/_virtual/context.js +4 -0
  556. package/lib/esm/_virtual/context.js.map +1 -0
  557. package/lib/esm/_virtual/github.js +6 -0
  558. package/lib/esm/_virtual/github.js.map +1 -0
  559. package/lib/esm/_virtual/github2.js +4 -0
  560. package/lib/esm/_virtual/github2.js.map +1 -0
  561. package/lib/esm/_virtual/index10.js +4 -0
  562. package/lib/esm/_virtual/index10.js.map +1 -0
  563. package/lib/esm/_virtual/index11.js +4 -0
  564. package/lib/esm/_virtual/index11.js.map +1 -0
  565. package/lib/esm/_virtual/index12.js +4 -0
  566. package/lib/esm/_virtual/index12.js.map +1 -0
  567. package/lib/esm/_virtual/index13.js +4 -0
  568. package/lib/esm/_virtual/index13.js.map +1 -0
  569. package/lib/esm/_virtual/index14.js +4 -0
  570. package/lib/esm/_virtual/index14.js.map +1 -0
  571. package/lib/esm/_virtual/index2.js +4 -5
  572. package/lib/esm/_virtual/index2.js.map +1 -1
  573. package/lib/esm/_virtual/index3.js +5 -2
  574. package/lib/esm/_virtual/index3.js.map +1 -1
  575. package/lib/esm/_virtual/index4.js +5 -2
  576. package/lib/esm/_virtual/index4.js.map +1 -1
  577. package/lib/esm/_virtual/index5.js +2 -2
  578. package/lib/esm/_virtual/index6.js +6 -2
  579. package/lib/esm/_virtual/index6.js.map +1 -1
  580. package/lib/esm/_virtual/index7.js +4 -0
  581. package/lib/esm/_virtual/index7.js.map +1 -0
  582. package/lib/esm/_virtual/index8.js +6 -0
  583. package/lib/esm/_virtual/index8.js.map +1 -0
  584. package/lib/esm/_virtual/index9.js +4 -0
  585. package/lib/esm/_virtual/index9.js.map +1 -0
  586. package/lib/esm/_virtual/main.js +4 -0
  587. package/lib/esm/_virtual/main.js.map +1 -0
  588. package/lib/esm/_virtual/mock-interceptor.js +4 -0
  589. package/lib/esm/_virtual/mock-interceptor.js.map +1 -0
  590. package/lib/esm/_virtual/proxy.js +4 -0
  591. package/lib/esm/_virtual/proxy.js.map +1 -0
  592. package/lib/esm/_virtual/tunnel.js +4 -0
  593. package/lib/esm/_virtual/tunnel.js.map +1 -0
  594. package/lib/esm/_virtual/utils.js +4 -0
  595. package/lib/esm/_virtual/utils.js.map +1 -0
  596. package/lib/esm/_virtual/utils2.js +4 -0
  597. package/lib/esm/_virtual/utils2.js.map +1 -0
  598. package/lib/esm/_virtual/utils3.js +4 -0
  599. package/lib/esm/_virtual/utils3.js.map +1 -0
  600. package/lib/esm/artifacts/filter-artifacts.js.map +1 -1
  601. package/lib/esm/env/ci-env.js +6 -1
  602. package/lib/esm/env/ci-env.js.map +1 -1
  603. package/lib/esm/env/load.js +1 -1
  604. package/lib/esm/env/load.js.map +1 -1
  605. package/lib/esm/env/service/github.js +3 -3
  606. package/lib/esm/env/service/github.js.map +1 -1
  607. package/lib/esm/ingest/ingest.js +1 -1
  608. package/lib/esm/ingest/ingest.js.map +1 -1
  609. package/lib/esm/locales/en.js.map +1 -1
  610. package/package.json +11 -11
@@ -0,0 +1,2305 @@
1
+ import require$$0$1 from 'node:assert';
2
+ import require$$0$2 from 'node:net';
3
+ import require$$2 from 'node:http';
4
+ import require$$0 from 'node:stream';
5
+ import { __require as requireUtil } from './core/util.js';
6
+ import { __require as requireTimers } from './timers.js';
7
+ import { __require as requireRequest } from './core/request.js';
8
+ import { __require as requireDispatcherBase } from './dispatcher-base.js';
9
+ import { __require as requireErrors } from './core/errors.js';
10
+ import { __require as requireConnect } from './core/connect.js';
11
+ import { __require as requireSymbols } from './core/symbols.js';
12
+ import { __require as requireConstants } from './llhttp/constants.js';
13
+ import { __require as requireRedirectInterceptor } from './interceptor/redirectInterceptor.js';
14
+ import { __require as requireLlhttpWasm } from './llhttp/llhttp-wasm.js';
15
+ import { __require as requireLlhttp_simdWasm } from './llhttp/llhttp_simd-wasm.js';
16
+
17
+ var client;
18
+ var hasRequiredClient;
19
+
20
+ function requireClient () {
21
+ if (hasRequiredClient) return client;
22
+ hasRequiredClient = 1;
23
+
24
+ /* global WebAssembly */
25
+
26
+ const assert = require$$0$1;
27
+ const net = require$$0$2;
28
+ const http = require$$2;
29
+ const { pipeline } = require$$0;
30
+ const util = requireUtil();
31
+ const timers = requireTimers();
32
+ const Request = requireRequest();
33
+ const DispatcherBase = requireDispatcherBase();
34
+ const {
35
+ RequestContentLengthMismatchError,
36
+ ResponseContentLengthMismatchError,
37
+ InvalidArgumentError,
38
+ RequestAbortedError,
39
+ HeadersTimeoutError,
40
+ HeadersOverflowError,
41
+ SocketError,
42
+ InformationalError,
43
+ BodyTimeoutError,
44
+ HTTPParserError,
45
+ ResponseExceededMaxSizeError,
46
+ ClientDestroyedError
47
+ } = requireErrors();
48
+ const buildConnector = requireConnect();
49
+ const {
50
+ kUrl,
51
+ kReset,
52
+ kServerName,
53
+ kClient,
54
+ kBusy,
55
+ kParser,
56
+ kConnect,
57
+ kBlocking,
58
+ kResuming,
59
+ kRunning,
60
+ kPending,
61
+ kSize,
62
+ kWriting,
63
+ kQueue,
64
+ kConnected,
65
+ kConnecting,
66
+ kNeedDrain,
67
+ kNoRef,
68
+ kKeepAliveDefaultTimeout,
69
+ kHostHeader,
70
+ kPendingIdx,
71
+ kRunningIdx,
72
+ kError,
73
+ kPipelining,
74
+ kSocket,
75
+ kKeepAliveTimeoutValue,
76
+ kMaxHeadersSize,
77
+ kKeepAliveMaxTimeout,
78
+ kKeepAliveTimeoutThreshold,
79
+ kHeadersTimeout,
80
+ kBodyTimeout,
81
+ kStrictContentLength,
82
+ kConnector,
83
+ kMaxRedirections,
84
+ kMaxRequests,
85
+ kCounter,
86
+ kClose,
87
+ kDestroy,
88
+ kDispatch,
89
+ kInterceptors,
90
+ kLocalAddress,
91
+ kMaxResponseSize,
92
+ kHTTPConnVersion,
93
+ // HTTP2
94
+ kHost,
95
+ kHTTP2Session,
96
+ kHTTP2SessionState,
97
+ kHTTP2BuildRequest,
98
+ kHTTP2CopyHeaders,
99
+ kHTTP1BuildRequest
100
+ } = requireSymbols();
101
+
102
+ /** @type {import('http2')} */
103
+ let http2;
104
+ try {
105
+ http2 = require('http2');
106
+ } catch {
107
+ // @ts-ignore
108
+ http2 = { constants: {} };
109
+ }
110
+
111
+ const {
112
+ constants: {
113
+ HTTP2_HEADER_AUTHORITY,
114
+ HTTP2_HEADER_METHOD,
115
+ HTTP2_HEADER_PATH,
116
+ HTTP2_HEADER_SCHEME,
117
+ HTTP2_HEADER_CONTENT_LENGTH,
118
+ HTTP2_HEADER_EXPECT,
119
+ HTTP2_HEADER_STATUS
120
+ }
121
+ } = http2;
122
+
123
+ // Experimental
124
+ let h2ExperimentalWarned = false;
125
+
126
+ const FastBuffer = Buffer[Symbol.species];
127
+
128
+ const kClosedResolve = Symbol('kClosedResolve');
129
+
130
+ const channels = {};
131
+
132
+ try {
133
+ const diagnosticsChannel = require('diagnostics_channel');
134
+ channels.sendHeaders = diagnosticsChannel.channel('undici:client:sendHeaders');
135
+ channels.beforeConnect = diagnosticsChannel.channel('undici:client:beforeConnect');
136
+ channels.connectError = diagnosticsChannel.channel('undici:client:connectError');
137
+ channels.connected = diagnosticsChannel.channel('undici:client:connected');
138
+ } catch {
139
+ channels.sendHeaders = { hasSubscribers: false };
140
+ channels.beforeConnect = { hasSubscribers: false };
141
+ channels.connectError = { hasSubscribers: false };
142
+ channels.connected = { hasSubscribers: false };
143
+ }
144
+
145
+ /**
146
+ * @type {import('../types/client').default}
147
+ */
148
+ class Client extends DispatcherBase {
149
+ /**
150
+ *
151
+ * @param {string|URL} url
152
+ * @param {import('../types/client').Client.Options} options
153
+ */
154
+ constructor (url, {
155
+ interceptors,
156
+ maxHeaderSize,
157
+ headersTimeout,
158
+ socketTimeout,
159
+ requestTimeout,
160
+ connectTimeout,
161
+ bodyTimeout,
162
+ idleTimeout,
163
+ keepAlive,
164
+ keepAliveTimeout,
165
+ maxKeepAliveTimeout,
166
+ keepAliveMaxTimeout,
167
+ keepAliveTimeoutThreshold,
168
+ socketPath,
169
+ pipelining,
170
+ tls,
171
+ strictContentLength,
172
+ maxCachedSessions,
173
+ maxRedirections,
174
+ connect,
175
+ maxRequestsPerClient,
176
+ localAddress,
177
+ maxResponseSize,
178
+ autoSelectFamily,
179
+ autoSelectFamilyAttemptTimeout,
180
+ // h2
181
+ allowH2,
182
+ maxConcurrentStreams
183
+ } = {}) {
184
+ super();
185
+
186
+ if (keepAlive !== undefined) {
187
+ throw new InvalidArgumentError('unsupported keepAlive, use pipelining=0 instead')
188
+ }
189
+
190
+ if (socketTimeout !== undefined) {
191
+ throw new InvalidArgumentError('unsupported socketTimeout, use headersTimeout & bodyTimeout instead')
192
+ }
193
+
194
+ if (requestTimeout !== undefined) {
195
+ throw new InvalidArgumentError('unsupported requestTimeout, use headersTimeout & bodyTimeout instead')
196
+ }
197
+
198
+ if (idleTimeout !== undefined) {
199
+ throw new InvalidArgumentError('unsupported idleTimeout, use keepAliveTimeout instead')
200
+ }
201
+
202
+ if (maxKeepAliveTimeout !== undefined) {
203
+ throw new InvalidArgumentError('unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead')
204
+ }
205
+
206
+ if (maxHeaderSize != null && !Number.isFinite(maxHeaderSize)) {
207
+ throw new InvalidArgumentError('invalid maxHeaderSize')
208
+ }
209
+
210
+ if (socketPath != null && typeof socketPath !== 'string') {
211
+ throw new InvalidArgumentError('invalid socketPath')
212
+ }
213
+
214
+ if (connectTimeout != null && (!Number.isFinite(connectTimeout) || connectTimeout < 0)) {
215
+ throw new InvalidArgumentError('invalid connectTimeout')
216
+ }
217
+
218
+ if (keepAliveTimeout != null && (!Number.isFinite(keepAliveTimeout) || keepAliveTimeout <= 0)) {
219
+ throw new InvalidArgumentError('invalid keepAliveTimeout')
220
+ }
221
+
222
+ if (keepAliveMaxTimeout != null && (!Number.isFinite(keepAliveMaxTimeout) || keepAliveMaxTimeout <= 0)) {
223
+ throw new InvalidArgumentError('invalid keepAliveMaxTimeout')
224
+ }
225
+
226
+ if (keepAliveTimeoutThreshold != null && !Number.isFinite(keepAliveTimeoutThreshold)) {
227
+ throw new InvalidArgumentError('invalid keepAliveTimeoutThreshold')
228
+ }
229
+
230
+ if (headersTimeout != null && (!Number.isInteger(headersTimeout) || headersTimeout < 0)) {
231
+ throw new InvalidArgumentError('headersTimeout must be a positive integer or zero')
232
+ }
233
+
234
+ if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) {
235
+ throw new InvalidArgumentError('bodyTimeout must be a positive integer or zero')
236
+ }
237
+
238
+ if (connect != null && typeof connect !== 'function' && typeof connect !== 'object') {
239
+ throw new InvalidArgumentError('connect must be a function or an object')
240
+ }
241
+
242
+ if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
243
+ throw new InvalidArgumentError('maxRedirections must be a positive number')
244
+ }
245
+
246
+ if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
247
+ throw new InvalidArgumentError('maxRequestsPerClient must be a positive number')
248
+ }
249
+
250
+ if (localAddress != null && (typeof localAddress !== 'string' || net.isIP(localAddress) === 0)) {
251
+ throw new InvalidArgumentError('localAddress must be valid string IP address')
252
+ }
253
+
254
+ if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
255
+ throw new InvalidArgumentError('maxResponseSize must be a positive number')
256
+ }
257
+
258
+ if (
259
+ autoSelectFamilyAttemptTimeout != null &&
260
+ (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)
261
+ ) {
262
+ throw new InvalidArgumentError('autoSelectFamilyAttemptTimeout must be a positive number')
263
+ }
264
+
265
+ // h2
266
+ if (allowH2 != null && typeof allowH2 !== 'boolean') {
267
+ throw new InvalidArgumentError('allowH2 must be a valid boolean value')
268
+ }
269
+
270
+ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== 'number' || maxConcurrentStreams < 1)) {
271
+ throw new InvalidArgumentError('maxConcurrentStreams must be a possitive integer, greater than 0')
272
+ }
273
+
274
+ if (typeof connect !== 'function') {
275
+ connect = buildConnector({
276
+ ...tls,
277
+ maxCachedSessions,
278
+ allowH2,
279
+ socketPath,
280
+ timeout: connectTimeout,
281
+ ...(util.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
282
+ ...connect
283
+ });
284
+ }
285
+
286
+ this[kInterceptors] = interceptors && interceptors.Client && Array.isArray(interceptors.Client)
287
+ ? interceptors.Client
288
+ : [createRedirectInterceptor({ maxRedirections })];
289
+ this[kUrl] = util.parseOrigin(url);
290
+ this[kConnector] = connect;
291
+ this[kSocket] = null;
292
+ this[kPipelining] = pipelining != null ? pipelining : 1;
293
+ this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize;
294
+ this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout;
295
+ this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 600e3 : keepAliveMaxTimeout;
296
+ this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 1e3 : keepAliveTimeoutThreshold;
297
+ this[kKeepAliveTimeoutValue] = this[kKeepAliveDefaultTimeout];
298
+ this[kServerName] = null;
299
+ this[kLocalAddress] = localAddress != null ? localAddress : null;
300
+ this[kResuming] = 0; // 0, idle, 1, scheduled, 2 resuming
301
+ this[kNeedDrain] = 0; // 0, idle, 1, scheduled, 2 resuming
302
+ this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}\r\n`;
303
+ this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 300e3;
304
+ this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 300e3;
305
+ this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength;
306
+ this[kMaxRedirections] = maxRedirections;
307
+ this[kMaxRequests] = maxRequestsPerClient;
308
+ this[kClosedResolve] = null;
309
+ this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
310
+ this[kHTTPConnVersion] = 'h1';
311
+
312
+ // HTTP/2
313
+ this[kHTTP2Session] = null;
314
+ this[kHTTP2SessionState] = !allowH2
315
+ ? null
316
+ : {
317
+ // streams: null, // Fixed queue of streams - For future support of `push`
318
+ openStreams: 0, // Keep track of them to decide wether or not unref the session
319
+ maxConcurrentStreams: maxConcurrentStreams != null ? maxConcurrentStreams : 100 // Max peerConcurrentStreams for a Node h2 server
320
+ };
321
+ this[kHost] = `${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}`;
322
+
323
+ // kQueue is built up of 3 sections separated by
324
+ // the kRunningIdx and kPendingIdx indices.
325
+ // | complete | running | pending |
326
+ // ^ kRunningIdx ^ kPendingIdx ^ kQueue.length
327
+ // kRunningIdx points to the first running element.
328
+ // kPendingIdx points to the first pending element.
329
+ // This implements a fast queue with an amortized
330
+ // time of O(1).
331
+
332
+ this[kQueue] = [];
333
+ this[kRunningIdx] = 0;
334
+ this[kPendingIdx] = 0;
335
+ }
336
+
337
+ get pipelining () {
338
+ return this[kPipelining]
339
+ }
340
+
341
+ set pipelining (value) {
342
+ this[kPipelining] = value;
343
+ resume(this, true);
344
+ }
345
+
346
+ get [kPending] () {
347
+ return this[kQueue].length - this[kPendingIdx]
348
+ }
349
+
350
+ get [kRunning] () {
351
+ return this[kPendingIdx] - this[kRunningIdx]
352
+ }
353
+
354
+ get [kSize] () {
355
+ return this[kQueue].length - this[kRunningIdx]
356
+ }
357
+
358
+ get [kConnected] () {
359
+ return !!this[kSocket] && !this[kConnecting] && !this[kSocket].destroyed
360
+ }
361
+
362
+ get [kBusy] () {
363
+ const socket = this[kSocket];
364
+ return (
365
+ (socket && (socket[kReset] || socket[kWriting] || socket[kBlocking])) ||
366
+ (this[kSize] >= (this[kPipelining] || 1)) ||
367
+ this[kPending] > 0
368
+ )
369
+ }
370
+
371
+ /* istanbul ignore: only used for test */
372
+ [kConnect] (cb) {
373
+ connect(this);
374
+ this.once('connect', cb);
375
+ }
376
+
377
+ [kDispatch] (opts, handler) {
378
+ const origin = opts.origin || this[kUrl].origin;
379
+
380
+ const request = this[kHTTPConnVersion] === 'h2'
381
+ ? Request[kHTTP2BuildRequest](origin, opts, handler)
382
+ : Request[kHTTP1BuildRequest](origin, opts, handler);
383
+
384
+ this[kQueue].push(request);
385
+ if (this[kResuming]) ; else if (util.bodyLength(request.body) == null && util.isIterable(request.body)) {
386
+ // Wait a tick in case stream/iterator is ended in the same tick.
387
+ this[kResuming] = 1;
388
+ process.nextTick(resume, this);
389
+ } else {
390
+ resume(this, true);
391
+ }
392
+
393
+ if (this[kResuming] && this[kNeedDrain] !== 2 && this[kBusy]) {
394
+ this[kNeedDrain] = 2;
395
+ }
396
+
397
+ return this[kNeedDrain] < 2
398
+ }
399
+
400
+ async [kClose] () {
401
+ // TODO: for H2 we need to gracefully flush the remaining enqueued
402
+ // request and close each stream.
403
+ return new Promise((resolve) => {
404
+ if (!this[kSize]) {
405
+ resolve(null);
406
+ } else {
407
+ this[kClosedResolve] = resolve;
408
+ }
409
+ })
410
+ }
411
+
412
+ async [kDestroy] (err) {
413
+ return new Promise((resolve) => {
414
+ const requests = this[kQueue].splice(this[kPendingIdx]);
415
+ for (let i = 0; i < requests.length; i++) {
416
+ const request = requests[i];
417
+ errorRequest(this, request, err);
418
+ }
419
+
420
+ const callback = () => {
421
+ if (this[kClosedResolve]) {
422
+ // TODO (fix): Should we error here with ClientDestroyedError?
423
+ this[kClosedResolve]();
424
+ this[kClosedResolve] = null;
425
+ }
426
+ resolve();
427
+ };
428
+
429
+ if (this[kHTTP2Session] != null) {
430
+ util.destroy(this[kHTTP2Session], err);
431
+ this[kHTTP2Session] = null;
432
+ this[kHTTP2SessionState] = null;
433
+ }
434
+
435
+ if (!this[kSocket]) {
436
+ queueMicrotask(callback);
437
+ } else {
438
+ util.destroy(this[kSocket].on('close', callback), err);
439
+ }
440
+
441
+ resume(this);
442
+ })
443
+ }
444
+ }
445
+
446
+ function onHttp2SessionError (err) {
447
+ assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID');
448
+
449
+ this[kSocket][kError] = err;
450
+
451
+ onError(this[kClient], err);
452
+ }
453
+
454
+ function onHttp2FrameError (type, code, id) {
455
+ const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
456
+
457
+ if (id === 0) {
458
+ this[kSocket][kError] = err;
459
+ onError(this[kClient], err);
460
+ }
461
+ }
462
+
463
+ function onHttp2SessionEnd () {
464
+ util.destroy(this, new SocketError('other side closed'));
465
+ util.destroy(this[kSocket], new SocketError('other side closed'));
466
+ }
467
+
468
+ function onHTTP2GoAway (code) {
469
+ const client = this[kClient];
470
+ const err = new InformationalError(`HTTP/2: "GOAWAY" frame received with code ${code}`);
471
+ client[kSocket] = null;
472
+ client[kHTTP2Session] = null;
473
+
474
+ if (client.destroyed) {
475
+ assert(this[kPending] === 0);
476
+
477
+ // Fail entire queue.
478
+ const requests = client[kQueue].splice(client[kRunningIdx]);
479
+ for (let i = 0; i < requests.length; i++) {
480
+ const request = requests[i];
481
+ errorRequest(this, request, err);
482
+ }
483
+ } else if (client[kRunning] > 0) {
484
+ // Fail head of pipeline.
485
+ const request = client[kQueue][client[kRunningIdx]];
486
+ client[kQueue][client[kRunningIdx]++] = null;
487
+
488
+ errorRequest(client, request, err);
489
+ }
490
+
491
+ client[kPendingIdx] = client[kRunningIdx];
492
+
493
+ assert(client[kRunning] === 0);
494
+
495
+ client.emit('disconnect',
496
+ client[kUrl],
497
+ [client],
498
+ err
499
+ );
500
+
501
+ resume(client);
502
+ }
503
+
504
+ const constants = requireConstants();
505
+ const createRedirectInterceptor = requireRedirectInterceptor();
506
+ const EMPTY_BUF = Buffer.alloc(0);
507
+
508
+ async function lazyllhttp () {
509
+ const llhttpWasmData = process.env.JEST_WORKER_ID ? requireLlhttpWasm() : undefined;
510
+
511
+ let mod;
512
+ try {
513
+ mod = await WebAssembly.compile(Buffer.from(requireLlhttp_simdWasm(), 'base64'));
514
+ } catch (e) {
515
+ /* istanbul ignore next */
516
+
517
+ // We could check if the error was caused by the simd option not
518
+ // being enabled, but the occurring of this other error
519
+ // * https://github.com/emscripten-core/emscripten/issues/11495
520
+ // got me to remove that check to avoid breaking Node 12.
521
+ mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || requireLlhttpWasm(), 'base64'));
522
+ }
523
+
524
+ return await WebAssembly.instantiate(mod, {
525
+ env: {
526
+ /* eslint-disable camelcase */
527
+
528
+ wasm_on_url: (p, at, len) => {
529
+ /* istanbul ignore next */
530
+ return 0
531
+ },
532
+ wasm_on_status: (p, at, len) => {
533
+ assert.strictEqual(currentParser.ptr, p);
534
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset;
535
+ return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
536
+ },
537
+ wasm_on_message_begin: (p) => {
538
+ assert.strictEqual(currentParser.ptr, p);
539
+ return currentParser.onMessageBegin() || 0
540
+ },
541
+ wasm_on_header_field: (p, at, len) => {
542
+ assert.strictEqual(currentParser.ptr, p);
543
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset;
544
+ return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
545
+ },
546
+ wasm_on_header_value: (p, at, len) => {
547
+ assert.strictEqual(currentParser.ptr, p);
548
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset;
549
+ return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
550
+ },
551
+ wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => {
552
+ assert.strictEqual(currentParser.ptr, p);
553
+ return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0
554
+ },
555
+ wasm_on_body: (p, at, len) => {
556
+ assert.strictEqual(currentParser.ptr, p);
557
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset;
558
+ return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
559
+ },
560
+ wasm_on_message_complete: (p) => {
561
+ assert.strictEqual(currentParser.ptr, p);
562
+ return currentParser.onMessageComplete() || 0
563
+ }
564
+
565
+ /* eslint-enable camelcase */
566
+ }
567
+ })
568
+ }
569
+
570
+ let llhttpInstance = null;
571
+ let llhttpPromise = lazyllhttp();
572
+ llhttpPromise.catch();
573
+
574
+ let currentParser = null;
575
+ let currentBufferRef = null;
576
+ let currentBufferSize = 0;
577
+ let currentBufferPtr = null;
578
+
579
+ const TIMEOUT_HEADERS = 1;
580
+ const TIMEOUT_BODY = 2;
581
+ const TIMEOUT_IDLE = 3;
582
+
583
+ class Parser {
584
+ constructor (client, socket, { exports: exports$1 }) {
585
+ assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0);
586
+
587
+ this.llhttp = exports$1;
588
+ this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE);
589
+ this.client = client;
590
+ this.socket = socket;
591
+ this.timeout = null;
592
+ this.timeoutValue = null;
593
+ this.timeoutType = null;
594
+ this.statusCode = null;
595
+ this.statusText = '';
596
+ this.upgrade = false;
597
+ this.headers = [];
598
+ this.headersSize = 0;
599
+ this.headersMaxSize = client[kMaxHeadersSize];
600
+ this.shouldKeepAlive = false;
601
+ this.paused = false;
602
+ this.resume = this.resume.bind(this);
603
+
604
+ this.bytesRead = 0;
605
+
606
+ this.keepAlive = '';
607
+ this.contentLength = '';
608
+ this.connection = '';
609
+ this.maxResponseSize = client[kMaxResponseSize];
610
+ }
611
+
612
+ setTimeout (value, type) {
613
+ this.timeoutType = type;
614
+ if (value !== this.timeoutValue) {
615
+ timers.clearTimeout(this.timeout);
616
+ if (value) {
617
+ this.timeout = timers.setTimeout(onParserTimeout, value, this);
618
+ // istanbul ignore else: only for jest
619
+ if (this.timeout.unref) {
620
+ this.timeout.unref();
621
+ }
622
+ } else {
623
+ this.timeout = null;
624
+ }
625
+ this.timeoutValue = value;
626
+ } else if (this.timeout) {
627
+ // istanbul ignore else: only for jest
628
+ if (this.timeout.refresh) {
629
+ this.timeout.refresh();
630
+ }
631
+ }
632
+ }
633
+
634
+ resume () {
635
+ if (this.socket.destroyed || !this.paused) {
636
+ return
637
+ }
638
+
639
+ assert(this.ptr != null);
640
+ assert(currentParser == null);
641
+
642
+ this.llhttp.llhttp_resume(this.ptr);
643
+
644
+ assert(this.timeoutType === TIMEOUT_BODY);
645
+ if (this.timeout) {
646
+ // istanbul ignore else: only for jest
647
+ if (this.timeout.refresh) {
648
+ this.timeout.refresh();
649
+ }
650
+ }
651
+
652
+ this.paused = false;
653
+ this.execute(this.socket.read() || EMPTY_BUF); // Flush parser.
654
+ this.readMore();
655
+ }
656
+
657
+ readMore () {
658
+ while (!this.paused && this.ptr) {
659
+ const chunk = this.socket.read();
660
+ if (chunk === null) {
661
+ break
662
+ }
663
+ this.execute(chunk);
664
+ }
665
+ }
666
+
667
+ execute (data) {
668
+ assert(this.ptr != null);
669
+ assert(currentParser == null);
670
+ assert(!this.paused);
671
+
672
+ const { socket, llhttp } = this;
673
+
674
+ if (data.length > currentBufferSize) {
675
+ if (currentBufferPtr) {
676
+ llhttp.free(currentBufferPtr);
677
+ }
678
+ currentBufferSize = Math.ceil(data.length / 4096) * 4096;
679
+ currentBufferPtr = llhttp.malloc(currentBufferSize);
680
+ }
681
+
682
+ new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize).set(data);
683
+
684
+ // Call `execute` on the wasm parser.
685
+ // We pass the `llhttp_parser` pointer address, the pointer address of buffer view data,
686
+ // and finally the length of bytes to parse.
687
+ // The return value is an error code or `constants.ERROR.OK`.
688
+ try {
689
+ let ret;
690
+
691
+ try {
692
+ currentBufferRef = data;
693
+ currentParser = this;
694
+ ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, data.length);
695
+ /* eslint-disable-next-line no-useless-catch */
696
+ } catch (err) {
697
+ /* istanbul ignore next: difficult to make a test case for */
698
+ throw err
699
+ } finally {
700
+ currentParser = null;
701
+ currentBufferRef = null;
702
+ }
703
+
704
+ const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr;
705
+
706
+ if (ret === constants.ERROR.PAUSED_UPGRADE) {
707
+ this.onUpgrade(data.slice(offset));
708
+ } else if (ret === constants.ERROR.PAUSED) {
709
+ this.paused = true;
710
+ socket.unshift(data.slice(offset));
711
+ } else if (ret !== constants.ERROR.OK) {
712
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr);
713
+ let message = '';
714
+ /* istanbul ignore else: difficult to make a test case for */
715
+ if (ptr) {
716
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
717
+ message =
718
+ 'Response does not match the HTTP/1.1 protocol (' +
719
+ Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
720
+ ')';
721
+ }
722
+ throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
723
+ }
724
+ } catch (err) {
725
+ util.destroy(socket, err);
726
+ }
727
+ }
728
+
729
+ destroy () {
730
+ assert(this.ptr != null);
731
+ assert(currentParser == null);
732
+
733
+ this.llhttp.llhttp_free(this.ptr);
734
+ this.ptr = null;
735
+
736
+ timers.clearTimeout(this.timeout);
737
+ this.timeout = null;
738
+ this.timeoutValue = null;
739
+ this.timeoutType = null;
740
+
741
+ this.paused = false;
742
+ }
743
+
744
+ onStatus (buf) {
745
+ this.statusText = buf.toString();
746
+ }
747
+
748
+ onMessageBegin () {
749
+ const { socket, client } = this;
750
+
751
+ /* istanbul ignore next: difficult to make a test case for */
752
+ if (socket.destroyed) {
753
+ return -1
754
+ }
755
+
756
+ const request = client[kQueue][client[kRunningIdx]];
757
+ if (!request) {
758
+ return -1
759
+ }
760
+ }
761
+
762
+ onHeaderField (buf) {
763
+ const len = this.headers.length;
764
+
765
+ if ((len & 1) === 0) {
766
+ this.headers.push(buf);
767
+ } else {
768
+ this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf]);
769
+ }
770
+
771
+ this.trackHeader(buf.length);
772
+ }
773
+
774
+ onHeaderValue (buf) {
775
+ let len = this.headers.length;
776
+
777
+ if ((len & 1) === 1) {
778
+ this.headers.push(buf);
779
+ len += 1;
780
+ } else {
781
+ this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf]);
782
+ }
783
+
784
+ const key = this.headers[len - 2];
785
+ if (key.length === 10 && key.toString().toLowerCase() === 'keep-alive') {
786
+ this.keepAlive += buf.toString();
787
+ } else if (key.length === 10 && key.toString().toLowerCase() === 'connection') {
788
+ this.connection += buf.toString();
789
+ } else if (key.length === 14 && key.toString().toLowerCase() === 'content-length') {
790
+ this.contentLength += buf.toString();
791
+ }
792
+
793
+ this.trackHeader(buf.length);
794
+ }
795
+
796
+ trackHeader (len) {
797
+ this.headersSize += len;
798
+ if (this.headersSize >= this.headersMaxSize) {
799
+ util.destroy(this.socket, new HeadersOverflowError());
800
+ }
801
+ }
802
+
803
+ onUpgrade (head) {
804
+ const { upgrade, client, socket, headers, statusCode } = this;
805
+
806
+ assert(upgrade);
807
+
808
+ const request = client[kQueue][client[kRunningIdx]];
809
+ assert(request);
810
+
811
+ assert(!socket.destroyed);
812
+ assert(socket === client[kSocket]);
813
+ assert(!this.paused);
814
+ assert(request.upgrade || request.method === 'CONNECT');
815
+
816
+ this.statusCode = null;
817
+ this.statusText = '';
818
+ this.shouldKeepAlive = null;
819
+
820
+ assert(this.headers.length % 2 === 0);
821
+ this.headers = [];
822
+ this.headersSize = 0;
823
+
824
+ socket.unshift(head);
825
+
826
+ socket[kParser].destroy();
827
+ socket[kParser] = null;
828
+
829
+ socket[kClient] = null;
830
+ socket[kError] = null;
831
+ socket
832
+ .removeListener('error', onSocketError)
833
+ .removeListener('readable', onSocketReadable)
834
+ .removeListener('end', onSocketEnd)
835
+ .removeListener('close', onSocketClose);
836
+
837
+ client[kSocket] = null;
838
+ client[kQueue][client[kRunningIdx]++] = null;
839
+ client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'));
840
+
841
+ try {
842
+ request.onUpgrade(statusCode, headers, socket);
843
+ } catch (err) {
844
+ util.destroy(socket, err);
845
+ }
846
+
847
+ resume(client);
848
+ }
849
+
850
+ onHeadersComplete (statusCode, upgrade, shouldKeepAlive) {
851
+ const { client, socket, headers, statusText } = this;
852
+
853
+ /* istanbul ignore next: difficult to make a test case for */
854
+ if (socket.destroyed) {
855
+ return -1
856
+ }
857
+
858
+ const request = client[kQueue][client[kRunningIdx]];
859
+
860
+ /* istanbul ignore next: difficult to make a test case for */
861
+ if (!request) {
862
+ return -1
863
+ }
864
+
865
+ assert(!this.upgrade);
866
+ assert(this.statusCode < 200);
867
+
868
+ if (statusCode === 100) {
869
+ util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)));
870
+ return -1
871
+ }
872
+
873
+ /* this can only happen if server is misbehaving */
874
+ if (upgrade && !request.upgrade) {
875
+ util.destroy(socket, new SocketError('bad upgrade', util.getSocketInfo(socket)));
876
+ return -1
877
+ }
878
+
879
+ assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS);
880
+
881
+ this.statusCode = statusCode;
882
+ this.shouldKeepAlive = (
883
+ shouldKeepAlive ||
884
+ // Override llhttp value which does not allow keepAlive for HEAD.
885
+ (request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
886
+ );
887
+
888
+ if (this.statusCode >= 200) {
889
+ const bodyTimeout = request.bodyTimeout != null
890
+ ? request.bodyTimeout
891
+ : client[kBodyTimeout];
892
+ this.setTimeout(bodyTimeout, TIMEOUT_BODY);
893
+ } else if (this.timeout) {
894
+ // istanbul ignore else: only for jest
895
+ if (this.timeout.refresh) {
896
+ this.timeout.refresh();
897
+ }
898
+ }
899
+
900
+ if (request.method === 'CONNECT') {
901
+ assert(client[kRunning] === 1);
902
+ this.upgrade = true;
903
+ return 2
904
+ }
905
+
906
+ if (upgrade) {
907
+ assert(client[kRunning] === 1);
908
+ this.upgrade = true;
909
+ return 2
910
+ }
911
+
912
+ assert(this.headers.length % 2 === 0);
913
+ this.headers = [];
914
+ this.headersSize = 0;
915
+
916
+ if (this.shouldKeepAlive && client[kPipelining]) {
917
+ const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null;
918
+
919
+ if (keepAliveTimeout != null) {
920
+ const timeout = Math.min(
921
+ keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
922
+ client[kKeepAliveMaxTimeout]
923
+ );
924
+ if (timeout <= 0) {
925
+ socket[kReset] = true;
926
+ } else {
927
+ client[kKeepAliveTimeoutValue] = timeout;
928
+ }
929
+ } else {
930
+ client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout];
931
+ }
932
+ } else {
933
+ // Stop more requests from being dispatched.
934
+ socket[kReset] = true;
935
+ }
936
+
937
+ const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false;
938
+
939
+ if (request.aborted) {
940
+ return -1
941
+ }
942
+
943
+ if (request.method === 'HEAD') {
944
+ return 1
945
+ }
946
+
947
+ if (statusCode < 200) {
948
+ return 1
949
+ }
950
+
951
+ if (socket[kBlocking]) {
952
+ socket[kBlocking] = false;
953
+ resume(client);
954
+ }
955
+
956
+ return pause ? constants.ERROR.PAUSED : 0
957
+ }
958
+
959
+ onBody (buf) {
960
+ const { client, socket, statusCode, maxResponseSize } = this;
961
+
962
+ if (socket.destroyed) {
963
+ return -1
964
+ }
965
+
966
+ const request = client[kQueue][client[kRunningIdx]];
967
+ assert(request);
968
+
969
+ assert.strictEqual(this.timeoutType, TIMEOUT_BODY);
970
+ if (this.timeout) {
971
+ // istanbul ignore else: only for jest
972
+ if (this.timeout.refresh) {
973
+ this.timeout.refresh();
974
+ }
975
+ }
976
+
977
+ assert(statusCode >= 200);
978
+
979
+ if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
980
+ util.destroy(socket, new ResponseExceededMaxSizeError());
981
+ return -1
982
+ }
983
+
984
+ this.bytesRead += buf.length;
985
+
986
+ if (request.onData(buf) === false) {
987
+ return constants.ERROR.PAUSED
988
+ }
989
+ }
990
+
991
+ onMessageComplete () {
992
+ const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this;
993
+
994
+ if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
995
+ return -1
996
+ }
997
+
998
+ if (upgrade) {
999
+ return
1000
+ }
1001
+
1002
+ const request = client[kQueue][client[kRunningIdx]];
1003
+ assert(request);
1004
+
1005
+ assert(statusCode >= 100);
1006
+
1007
+ this.statusCode = null;
1008
+ this.statusText = '';
1009
+ this.bytesRead = 0;
1010
+ this.contentLength = '';
1011
+ this.keepAlive = '';
1012
+ this.connection = '';
1013
+
1014
+ assert(this.headers.length % 2 === 0);
1015
+ this.headers = [];
1016
+ this.headersSize = 0;
1017
+
1018
+ if (statusCode < 200) {
1019
+ return
1020
+ }
1021
+
1022
+ /* istanbul ignore next: should be handled by llhttp? */
1023
+ if (request.method !== 'HEAD' && contentLength && bytesRead !== parseInt(contentLength, 10)) {
1024
+ util.destroy(socket, new ResponseContentLengthMismatchError());
1025
+ return -1
1026
+ }
1027
+
1028
+ request.onComplete(headers);
1029
+
1030
+ client[kQueue][client[kRunningIdx]++] = null;
1031
+
1032
+ if (socket[kWriting]) {
1033
+ assert.strictEqual(client[kRunning], 0);
1034
+ // Response completed before request.
1035
+ util.destroy(socket, new InformationalError('reset'));
1036
+ return constants.ERROR.PAUSED
1037
+ } else if (!shouldKeepAlive) {
1038
+ util.destroy(socket, new InformationalError('reset'));
1039
+ return constants.ERROR.PAUSED
1040
+ } else if (socket[kReset] && client[kRunning] === 0) {
1041
+ // Destroy socket once all requests have completed.
1042
+ // The request at the tail of the pipeline is the one
1043
+ // that requested reset and no further requests should
1044
+ // have been queued since then.
1045
+ util.destroy(socket, new InformationalError('reset'));
1046
+ return constants.ERROR.PAUSED
1047
+ } else if (client[kPipelining] === 1) {
1048
+ // We must wait a full event loop cycle to reuse this socket to make sure
1049
+ // that non-spec compliant servers are not closing the connection even if they
1050
+ // said they won't.
1051
+ setImmediate(resume, client);
1052
+ } else {
1053
+ resume(client);
1054
+ }
1055
+ }
1056
+ }
1057
+
1058
+ function onParserTimeout (parser) {
1059
+ const { socket, timeoutType, client } = parser;
1060
+
1061
+ /* istanbul ignore else */
1062
+ if (timeoutType === TIMEOUT_HEADERS) {
1063
+ if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
1064
+ assert(!parser.paused, 'cannot be paused while waiting for headers');
1065
+ util.destroy(socket, new HeadersTimeoutError());
1066
+ }
1067
+ } else if (timeoutType === TIMEOUT_BODY) {
1068
+ if (!parser.paused) {
1069
+ util.destroy(socket, new BodyTimeoutError());
1070
+ }
1071
+ } else if (timeoutType === TIMEOUT_IDLE) {
1072
+ assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]);
1073
+ util.destroy(socket, new InformationalError('socket idle timeout'));
1074
+ }
1075
+ }
1076
+
1077
+ function onSocketReadable () {
1078
+ const { [kParser]: parser } = this;
1079
+ if (parser) {
1080
+ parser.readMore();
1081
+ }
1082
+ }
1083
+
1084
+ function onSocketError (err) {
1085
+ const { [kClient]: client, [kParser]: parser } = this;
1086
+
1087
+ assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID');
1088
+
1089
+ if (client[kHTTPConnVersion] !== 'h2') {
1090
+ // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
1091
+ // to the user.
1092
+ if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
1093
+ // We treat all incoming data so for as a valid response.
1094
+ parser.onMessageComplete();
1095
+ return
1096
+ }
1097
+ }
1098
+
1099
+ this[kError] = err;
1100
+
1101
+ onError(this[kClient], err);
1102
+ }
1103
+
1104
+ function onError (client, err) {
1105
+ if (
1106
+ client[kRunning] === 0 &&
1107
+ err.code !== 'UND_ERR_INFO' &&
1108
+ err.code !== 'UND_ERR_SOCKET'
1109
+ ) {
1110
+ // Error is not caused by running request and not a recoverable
1111
+ // socket error.
1112
+
1113
+ assert(client[kPendingIdx] === client[kRunningIdx]);
1114
+
1115
+ const requests = client[kQueue].splice(client[kRunningIdx]);
1116
+ for (let i = 0; i < requests.length; i++) {
1117
+ const request = requests[i];
1118
+ errorRequest(client, request, err);
1119
+ }
1120
+ assert(client[kSize] === 0);
1121
+ }
1122
+ }
1123
+
1124
+ function onSocketEnd () {
1125
+ const { [kParser]: parser, [kClient]: client } = this;
1126
+
1127
+ if (client[kHTTPConnVersion] !== 'h2') {
1128
+ if (parser.statusCode && !parser.shouldKeepAlive) {
1129
+ // We treat all incoming data so far as a valid response.
1130
+ parser.onMessageComplete();
1131
+ return
1132
+ }
1133
+ }
1134
+
1135
+ util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)));
1136
+ }
1137
+
1138
+ function onSocketClose () {
1139
+ const { [kClient]: client, [kParser]: parser } = this;
1140
+
1141
+ if (client[kHTTPConnVersion] === 'h1' && parser) {
1142
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
1143
+ // We treat all incoming data so far as a valid response.
1144
+ parser.onMessageComplete();
1145
+ }
1146
+
1147
+ this[kParser].destroy();
1148
+ this[kParser] = null;
1149
+ }
1150
+
1151
+ const err = this[kError] || new SocketError('closed', util.getSocketInfo(this));
1152
+
1153
+ client[kSocket] = null;
1154
+
1155
+ if (client.destroyed) {
1156
+ assert(client[kPending] === 0);
1157
+
1158
+ // Fail entire queue.
1159
+ const requests = client[kQueue].splice(client[kRunningIdx]);
1160
+ for (let i = 0; i < requests.length; i++) {
1161
+ const request = requests[i];
1162
+ errorRequest(client, request, err);
1163
+ }
1164
+ } else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') {
1165
+ // Fail head of pipeline.
1166
+ const request = client[kQueue][client[kRunningIdx]];
1167
+ client[kQueue][client[kRunningIdx]++] = null;
1168
+
1169
+ errorRequest(client, request, err);
1170
+ }
1171
+
1172
+ client[kPendingIdx] = client[kRunningIdx];
1173
+
1174
+ assert(client[kRunning] === 0);
1175
+
1176
+ client.emit('disconnect', client[kUrl], [client], err);
1177
+
1178
+ resume(client);
1179
+ }
1180
+
1181
+ async function connect (client) {
1182
+ assert(!client[kConnecting]);
1183
+ assert(!client[kSocket]);
1184
+
1185
+ let { host, hostname, protocol, port } = client[kUrl];
1186
+
1187
+ // Resolve ipv6
1188
+ if (hostname[0] === '[') {
1189
+ const idx = hostname.indexOf(']');
1190
+
1191
+ assert(idx !== -1);
1192
+ const ip = hostname.substring(1, idx);
1193
+
1194
+ assert(net.isIP(ip));
1195
+ hostname = ip;
1196
+ }
1197
+
1198
+ client[kConnecting] = true;
1199
+
1200
+ if (channels.beforeConnect.hasSubscribers) {
1201
+ channels.beforeConnect.publish({
1202
+ connectParams: {
1203
+ host,
1204
+ hostname,
1205
+ protocol,
1206
+ port,
1207
+ servername: client[kServerName],
1208
+ localAddress: client[kLocalAddress]
1209
+ },
1210
+ connector: client[kConnector]
1211
+ });
1212
+ }
1213
+
1214
+ try {
1215
+ const socket = await new Promise((resolve, reject) => {
1216
+ client[kConnector]({
1217
+ host,
1218
+ hostname,
1219
+ protocol,
1220
+ port,
1221
+ servername: client[kServerName],
1222
+ localAddress: client[kLocalAddress]
1223
+ }, (err, socket) => {
1224
+ if (err) {
1225
+ reject(err);
1226
+ } else {
1227
+ resolve(socket);
1228
+ }
1229
+ });
1230
+ });
1231
+
1232
+ if (client.destroyed) {
1233
+ util.destroy(socket.on('error', () => {}), new ClientDestroyedError());
1234
+ return
1235
+ }
1236
+
1237
+ client[kConnecting] = false;
1238
+
1239
+ assert(socket);
1240
+
1241
+ const isH2 = socket.alpnProtocol === 'h2';
1242
+ if (isH2) {
1243
+ if (!h2ExperimentalWarned) {
1244
+ h2ExperimentalWarned = true;
1245
+ process.emitWarning('H2 support is experimental, expect them to change at any time.', {
1246
+ code: 'UNDICI-H2'
1247
+ });
1248
+ }
1249
+
1250
+ const session = http2.connect(client[kUrl], {
1251
+ createConnection: () => socket,
1252
+ peerMaxConcurrentStreams: client[kHTTP2SessionState].maxConcurrentStreams
1253
+ });
1254
+
1255
+ client[kHTTPConnVersion] = 'h2';
1256
+ session[kClient] = client;
1257
+ session[kSocket] = socket;
1258
+ session.on('error', onHttp2SessionError);
1259
+ session.on('frameError', onHttp2FrameError);
1260
+ session.on('end', onHttp2SessionEnd);
1261
+ session.on('goaway', onHTTP2GoAway);
1262
+ session.on('close', onSocketClose);
1263
+ session.unref();
1264
+
1265
+ client[kHTTP2Session] = session;
1266
+ socket[kHTTP2Session] = session;
1267
+ } else {
1268
+ if (!llhttpInstance) {
1269
+ llhttpInstance = await llhttpPromise;
1270
+ llhttpPromise = null;
1271
+ }
1272
+
1273
+ socket[kNoRef] = false;
1274
+ socket[kWriting] = false;
1275
+ socket[kReset] = false;
1276
+ socket[kBlocking] = false;
1277
+ socket[kParser] = new Parser(client, socket, llhttpInstance);
1278
+ }
1279
+
1280
+ socket[kCounter] = 0;
1281
+ socket[kMaxRequests] = client[kMaxRequests];
1282
+ socket[kClient] = client;
1283
+ socket[kError] = null;
1284
+
1285
+ socket
1286
+ .on('error', onSocketError)
1287
+ .on('readable', onSocketReadable)
1288
+ .on('end', onSocketEnd)
1289
+ .on('close', onSocketClose);
1290
+
1291
+ client[kSocket] = socket;
1292
+
1293
+ if (channels.connected.hasSubscribers) {
1294
+ channels.connected.publish({
1295
+ connectParams: {
1296
+ host,
1297
+ hostname,
1298
+ protocol,
1299
+ port,
1300
+ servername: client[kServerName],
1301
+ localAddress: client[kLocalAddress]
1302
+ },
1303
+ connector: client[kConnector],
1304
+ socket
1305
+ });
1306
+ }
1307
+ client.emit('connect', client[kUrl], [client]);
1308
+ } catch (err) {
1309
+ if (client.destroyed) {
1310
+ return
1311
+ }
1312
+
1313
+ client[kConnecting] = false;
1314
+
1315
+ if (channels.connectError.hasSubscribers) {
1316
+ channels.connectError.publish({
1317
+ connectParams: {
1318
+ host,
1319
+ hostname,
1320
+ protocol,
1321
+ port,
1322
+ servername: client[kServerName],
1323
+ localAddress: client[kLocalAddress]
1324
+ },
1325
+ connector: client[kConnector],
1326
+ error: err
1327
+ });
1328
+ }
1329
+
1330
+ if (err.code === 'ERR_TLS_CERT_ALTNAME_INVALID') {
1331
+ assert(client[kRunning] === 0);
1332
+ while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) {
1333
+ const request = client[kQueue][client[kPendingIdx]++];
1334
+ errorRequest(client, request, err);
1335
+ }
1336
+ } else {
1337
+ onError(client, err);
1338
+ }
1339
+
1340
+ client.emit('connectionError', client[kUrl], [client], err);
1341
+ }
1342
+
1343
+ resume(client);
1344
+ }
1345
+
1346
+ function emitDrain (client) {
1347
+ client[kNeedDrain] = 0;
1348
+ client.emit('drain', client[kUrl], [client]);
1349
+ }
1350
+
1351
+ function resume (client, sync) {
1352
+ if (client[kResuming] === 2) {
1353
+ return
1354
+ }
1355
+
1356
+ client[kResuming] = 2;
1357
+
1358
+ _resume(client, sync);
1359
+ client[kResuming] = 0;
1360
+
1361
+ if (client[kRunningIdx] > 256) {
1362
+ client[kQueue].splice(0, client[kRunningIdx]);
1363
+ client[kPendingIdx] -= client[kRunningIdx];
1364
+ client[kRunningIdx] = 0;
1365
+ }
1366
+ }
1367
+
1368
+ function _resume (client, sync) {
1369
+ while (true) {
1370
+ if (client.destroyed) {
1371
+ assert(client[kPending] === 0);
1372
+ return
1373
+ }
1374
+
1375
+ if (client[kClosedResolve] && !client[kSize]) {
1376
+ client[kClosedResolve]();
1377
+ client[kClosedResolve] = null;
1378
+ return
1379
+ }
1380
+
1381
+ const socket = client[kSocket];
1382
+
1383
+ if (socket && !socket.destroyed && socket.alpnProtocol !== 'h2') {
1384
+ if (client[kSize] === 0) {
1385
+ if (!socket[kNoRef] && socket.unref) {
1386
+ socket.unref();
1387
+ socket[kNoRef] = true;
1388
+ }
1389
+ } else if (socket[kNoRef] && socket.ref) {
1390
+ socket.ref();
1391
+ socket[kNoRef] = false;
1392
+ }
1393
+
1394
+ if (client[kSize] === 0) {
1395
+ if (socket[kParser].timeoutType !== TIMEOUT_IDLE) {
1396
+ socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE);
1397
+ }
1398
+ } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
1399
+ if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
1400
+ const request = client[kQueue][client[kRunningIdx]];
1401
+ const headersTimeout = request.headersTimeout != null
1402
+ ? request.headersTimeout
1403
+ : client[kHeadersTimeout];
1404
+ socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS);
1405
+ }
1406
+ }
1407
+ }
1408
+
1409
+ if (client[kBusy]) {
1410
+ client[kNeedDrain] = 2;
1411
+ } else if (client[kNeedDrain] === 2) {
1412
+ if (sync) {
1413
+ client[kNeedDrain] = 1;
1414
+ process.nextTick(emitDrain, client);
1415
+ } else {
1416
+ emitDrain(client);
1417
+ }
1418
+ continue
1419
+ }
1420
+
1421
+ if (client[kPending] === 0) {
1422
+ return
1423
+ }
1424
+
1425
+ if (client[kRunning] >= (client[kPipelining] || 1)) {
1426
+ return
1427
+ }
1428
+
1429
+ const request = client[kQueue][client[kPendingIdx]];
1430
+
1431
+ if (client[kUrl].protocol === 'https:' && client[kServerName] !== request.servername) {
1432
+ if (client[kRunning] > 0) {
1433
+ return
1434
+ }
1435
+
1436
+ client[kServerName] = request.servername;
1437
+
1438
+ if (socket && socket.servername !== request.servername) {
1439
+ util.destroy(socket, new InformationalError('servername changed'));
1440
+ return
1441
+ }
1442
+ }
1443
+
1444
+ if (client[kConnecting]) {
1445
+ return
1446
+ }
1447
+
1448
+ if (!socket && !client[kHTTP2Session]) {
1449
+ connect(client);
1450
+ return
1451
+ }
1452
+
1453
+ if (socket.destroyed || socket[kWriting] || socket[kReset] || socket[kBlocking]) {
1454
+ return
1455
+ }
1456
+
1457
+ if (client[kRunning] > 0 && !request.idempotent) {
1458
+ // Non-idempotent request cannot be retried.
1459
+ // Ensure that no other requests are inflight and
1460
+ // could cause failure.
1461
+ return
1462
+ }
1463
+
1464
+ if (client[kRunning] > 0 && (request.upgrade || request.method === 'CONNECT')) {
1465
+ // Don't dispatch an upgrade until all preceding requests have completed.
1466
+ // A misbehaving server might upgrade the connection before all pipelined
1467
+ // request has completed.
1468
+ return
1469
+ }
1470
+
1471
+ if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
1472
+ (util.isStream(request.body) || util.isAsyncIterable(request.body))) {
1473
+ // Request with stream or iterator body can error while other requests
1474
+ // are inflight and indirectly error those as well.
1475
+ // Ensure this doesn't happen by waiting for inflight
1476
+ // to complete before dispatching.
1477
+
1478
+ // Request with stream or iterator body cannot be retried.
1479
+ // Ensure that no other requests are inflight and
1480
+ // could cause failure.
1481
+ return
1482
+ }
1483
+
1484
+ if (!request.aborted && write(client, request)) {
1485
+ client[kPendingIdx]++;
1486
+ } else {
1487
+ client[kQueue].splice(client[kPendingIdx], 1);
1488
+ }
1489
+ }
1490
+ }
1491
+
1492
+ // https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
1493
+ function shouldSendContentLength (method) {
1494
+ return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
1495
+ }
1496
+
1497
+ function write (client, request) {
1498
+ if (client[kHTTPConnVersion] === 'h2') {
1499
+ writeH2(client, client[kHTTP2Session], request);
1500
+ return
1501
+ }
1502
+
1503
+ const { body, method, path, host, upgrade, headers, blocking, reset } = request;
1504
+
1505
+ // https://tools.ietf.org/html/rfc7231#section-4.3.1
1506
+ // https://tools.ietf.org/html/rfc7231#section-4.3.2
1507
+ // https://tools.ietf.org/html/rfc7231#section-4.3.5
1508
+
1509
+ // Sending a payload body on a request that does not
1510
+ // expect it can cause undefined behavior on some
1511
+ // servers and corrupt connection state. Do not
1512
+ // re-use the connection for further requests.
1513
+
1514
+ const expectsPayload = (
1515
+ method === 'PUT' ||
1516
+ method === 'POST' ||
1517
+ method === 'PATCH'
1518
+ );
1519
+
1520
+ if (body && typeof body.read === 'function') {
1521
+ // Try to read EOF in order to get length.
1522
+ body.read(0);
1523
+ }
1524
+
1525
+ const bodyLength = util.bodyLength(body);
1526
+
1527
+ let contentLength = bodyLength;
1528
+
1529
+ if (contentLength === null) {
1530
+ contentLength = request.contentLength;
1531
+ }
1532
+
1533
+ if (contentLength === 0 && !expectsPayload) {
1534
+ // https://tools.ietf.org/html/rfc7230#section-3.3.2
1535
+ // A user agent SHOULD NOT send a Content-Length header field when
1536
+ // the request message does not contain a payload body and the method
1537
+ // semantics do not anticipate such a body.
1538
+
1539
+ contentLength = null;
1540
+ }
1541
+
1542
+ // https://github.com/nodejs/undici/issues/2046
1543
+ // A user agent may send a Content-Length header with 0 value, this should be allowed.
1544
+ if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
1545
+ if (client[kStrictContentLength]) {
1546
+ errorRequest(client, request, new RequestContentLengthMismatchError());
1547
+ return false
1548
+ }
1549
+
1550
+ process.emitWarning(new RequestContentLengthMismatchError());
1551
+ }
1552
+
1553
+ const socket = client[kSocket];
1554
+
1555
+ try {
1556
+ request.onConnect((err) => {
1557
+ if (request.aborted || request.completed) {
1558
+ return
1559
+ }
1560
+
1561
+ errorRequest(client, request, err || new RequestAbortedError());
1562
+
1563
+ util.destroy(socket, new InformationalError('aborted'));
1564
+ });
1565
+ } catch (err) {
1566
+ errorRequest(client, request, err);
1567
+ }
1568
+
1569
+ if (request.aborted) {
1570
+ return false
1571
+ }
1572
+
1573
+ if (method === 'HEAD') {
1574
+ // https://github.com/mcollina/undici/issues/258
1575
+ // Close after a HEAD request to interop with misbehaving servers
1576
+ // that may send a body in the response.
1577
+
1578
+ socket[kReset] = true;
1579
+ }
1580
+
1581
+ if (upgrade || method === 'CONNECT') {
1582
+ // On CONNECT or upgrade, block pipeline from dispatching further
1583
+ // requests on this connection.
1584
+
1585
+ socket[kReset] = true;
1586
+ }
1587
+
1588
+ if (reset != null) {
1589
+ socket[kReset] = reset;
1590
+ }
1591
+
1592
+ if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
1593
+ socket[kReset] = true;
1594
+ }
1595
+
1596
+ if (blocking) {
1597
+ socket[kBlocking] = true;
1598
+ }
1599
+
1600
+ let header = `${method} ${path} HTTP/1.1\r\n`;
1601
+
1602
+ if (typeof host === 'string') {
1603
+ header += `host: ${host}\r\n`;
1604
+ } else {
1605
+ header += client[kHostHeader];
1606
+ }
1607
+
1608
+ if (upgrade) {
1609
+ header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`;
1610
+ } else if (client[kPipelining] && !socket[kReset]) {
1611
+ header += 'connection: keep-alive\r\n';
1612
+ } else {
1613
+ header += 'connection: close\r\n';
1614
+ }
1615
+
1616
+ if (headers) {
1617
+ header += headers;
1618
+ }
1619
+
1620
+ if (channels.sendHeaders.hasSubscribers) {
1621
+ channels.sendHeaders.publish({ request, headers: header, socket });
1622
+ }
1623
+
1624
+ /* istanbul ignore else: assertion */
1625
+ if (!body || bodyLength === 0) {
1626
+ if (contentLength === 0) {
1627
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1');
1628
+ } else {
1629
+ assert(contentLength === null, 'no body must not have content length');
1630
+ socket.write(`${header}\r\n`, 'latin1');
1631
+ }
1632
+ request.onRequestSent();
1633
+ } else if (util.isBuffer(body)) {
1634
+ assert(contentLength === body.byteLength, 'buffer body must have content length');
1635
+
1636
+ socket.cork();
1637
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1');
1638
+ socket.write(body);
1639
+ socket.uncork();
1640
+ request.onBodySent(body);
1641
+ request.onRequestSent();
1642
+ if (!expectsPayload) {
1643
+ socket[kReset] = true;
1644
+ }
1645
+ } else if (util.isBlobLike(body)) {
1646
+ if (typeof body.stream === 'function') {
1647
+ writeIterable({ body: body.stream(), client, request, socket, contentLength, header, expectsPayload });
1648
+ } else {
1649
+ writeBlob({ body, client, request, socket, contentLength, header, expectsPayload });
1650
+ }
1651
+ } else if (util.isStream(body)) {
1652
+ writeStream({ body, client, request, socket, contentLength, header, expectsPayload });
1653
+ } else if (util.isIterable(body)) {
1654
+ writeIterable({ body, client, request, socket, contentLength, header, expectsPayload });
1655
+ } else {
1656
+ assert(false);
1657
+ }
1658
+
1659
+ return true
1660
+ }
1661
+
1662
+ function writeH2 (client, session, request) {
1663
+ const { body, method, path, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
1664
+
1665
+ let headers;
1666
+ if (typeof reqHeaders === 'string') headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
1667
+ else headers = reqHeaders;
1668
+
1669
+ if (upgrade) {
1670
+ errorRequest(client, request, new Error('Upgrade not supported for H2'));
1671
+ return false
1672
+ }
1673
+
1674
+ try {
1675
+ // TODO(HTTP/2): Should we call onConnect immediately or on stream ready event?
1676
+ request.onConnect((err) => {
1677
+ if (request.aborted || request.completed) {
1678
+ return
1679
+ }
1680
+
1681
+ errorRequest(client, request, err || new RequestAbortedError());
1682
+ });
1683
+ } catch (err) {
1684
+ errorRequest(client, request, err);
1685
+ }
1686
+
1687
+ if (request.aborted) {
1688
+ return false
1689
+ }
1690
+
1691
+ /** @type {import('node:http2').ClientHttp2Stream} */
1692
+ let stream;
1693
+ const h2State = client[kHTTP2SessionState];
1694
+
1695
+ headers[HTTP2_HEADER_AUTHORITY] = host || client[kHost];
1696
+ headers[HTTP2_HEADER_METHOD] = method;
1697
+
1698
+ if (method === 'CONNECT') {
1699
+ session.ref();
1700
+ // we are already connected, streams are pending, first request
1701
+ // will create a new stream. We trigger a request to create the stream and wait until
1702
+ // `ready` event is triggered
1703
+ // We disabled endStream to allow the user to write to the stream
1704
+ stream = session.request(headers, { endStream: false, signal });
1705
+
1706
+ if (stream.id && !stream.pending) {
1707
+ request.onUpgrade(null, null, stream);
1708
+ ++h2State.openStreams;
1709
+ } else {
1710
+ stream.once('ready', () => {
1711
+ request.onUpgrade(null, null, stream);
1712
+ ++h2State.openStreams;
1713
+ });
1714
+ }
1715
+
1716
+ stream.once('close', () => {
1717
+ h2State.openStreams -= 1;
1718
+ // TODO(HTTP/2): unref only if current streams count is 0
1719
+ if (h2State.openStreams === 0) session.unref();
1720
+ });
1721
+
1722
+ return true
1723
+ }
1724
+
1725
+ // https://tools.ietf.org/html/rfc7540#section-8.3
1726
+ // :path and :scheme headers must be omited when sending CONNECT
1727
+
1728
+ headers[HTTP2_HEADER_PATH] = path;
1729
+ headers[HTTP2_HEADER_SCHEME] = 'https';
1730
+
1731
+ // https://tools.ietf.org/html/rfc7231#section-4.3.1
1732
+ // https://tools.ietf.org/html/rfc7231#section-4.3.2
1733
+ // https://tools.ietf.org/html/rfc7231#section-4.3.5
1734
+
1735
+ // Sending a payload body on a request that does not
1736
+ // expect it can cause undefined behavior on some
1737
+ // servers and corrupt connection state. Do not
1738
+ // re-use the connection for further requests.
1739
+
1740
+ const expectsPayload = (
1741
+ method === 'PUT' ||
1742
+ method === 'POST' ||
1743
+ method === 'PATCH'
1744
+ );
1745
+
1746
+ if (body && typeof body.read === 'function') {
1747
+ // Try to read EOF in order to get length.
1748
+ body.read(0);
1749
+ }
1750
+
1751
+ let contentLength = util.bodyLength(body);
1752
+
1753
+ if (contentLength == null) {
1754
+ contentLength = request.contentLength;
1755
+ }
1756
+
1757
+ if (contentLength === 0 || !expectsPayload) {
1758
+ // https://tools.ietf.org/html/rfc7230#section-3.3.2
1759
+ // A user agent SHOULD NOT send a Content-Length header field when
1760
+ // the request message does not contain a payload body and the method
1761
+ // semantics do not anticipate such a body.
1762
+
1763
+ contentLength = null;
1764
+ }
1765
+
1766
+ // https://github.com/nodejs/undici/issues/2046
1767
+ // A user agent may send a Content-Length header with 0 value, this should be allowed.
1768
+ if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
1769
+ if (client[kStrictContentLength]) {
1770
+ errorRequest(client, request, new RequestContentLengthMismatchError());
1771
+ return false
1772
+ }
1773
+
1774
+ process.emitWarning(new RequestContentLengthMismatchError());
1775
+ }
1776
+
1777
+ if (contentLength != null) {
1778
+ assert(body, 'no body must not have content length');
1779
+ headers[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength}`;
1780
+ }
1781
+
1782
+ session.ref();
1783
+
1784
+ const shouldEndStream = method === 'GET' || method === 'HEAD';
1785
+ if (expectContinue) {
1786
+ headers[HTTP2_HEADER_EXPECT] = '100-continue';
1787
+ stream = session.request(headers, { endStream: shouldEndStream, signal });
1788
+
1789
+ stream.once('continue', writeBodyH2);
1790
+ } else {
1791
+ stream = session.request(headers, {
1792
+ endStream: shouldEndStream,
1793
+ signal
1794
+ });
1795
+ writeBodyH2();
1796
+ }
1797
+
1798
+ // Increment counter as we have new several streams open
1799
+ ++h2State.openStreams;
1800
+
1801
+ stream.once('response', headers => {
1802
+ const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers;
1803
+
1804
+ if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) {
1805
+ stream.pause();
1806
+ }
1807
+ });
1808
+
1809
+ stream.once('end', () => {
1810
+ request.onComplete([]);
1811
+ });
1812
+
1813
+ stream.on('data', (chunk) => {
1814
+ if (request.onData(chunk) === false) {
1815
+ stream.pause();
1816
+ }
1817
+ });
1818
+
1819
+ stream.once('close', () => {
1820
+ h2State.openStreams -= 1;
1821
+ // TODO(HTTP/2): unref only if current streams count is 0
1822
+ if (h2State.openStreams === 0) {
1823
+ session.unref();
1824
+ }
1825
+ });
1826
+
1827
+ stream.once('error', function (err) {
1828
+ if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
1829
+ h2State.streams -= 1;
1830
+ util.destroy(stream, err);
1831
+ }
1832
+ });
1833
+
1834
+ stream.once('frameError', (type, code) => {
1835
+ const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`);
1836
+ errorRequest(client, request, err);
1837
+
1838
+ if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) {
1839
+ h2State.streams -= 1;
1840
+ util.destroy(stream, err);
1841
+ }
1842
+ });
1843
+
1844
+ // stream.on('aborted', () => {
1845
+ // // TODO(HTTP/2): Support aborted
1846
+ // })
1847
+
1848
+ // stream.on('timeout', () => {
1849
+ // // TODO(HTTP/2): Support timeout
1850
+ // })
1851
+
1852
+ // stream.on('push', headers => {
1853
+ // // TODO(HTTP/2): Suppor push
1854
+ // })
1855
+
1856
+ // stream.on('trailers', headers => {
1857
+ // // TODO(HTTP/2): Support trailers
1858
+ // })
1859
+
1860
+ return true
1861
+
1862
+ function writeBodyH2 () {
1863
+ /* istanbul ignore else: assertion */
1864
+ if (!body) {
1865
+ request.onRequestSent();
1866
+ } else if (util.isBuffer(body)) {
1867
+ assert(contentLength === body.byteLength, 'buffer body must have content length');
1868
+ stream.cork();
1869
+ stream.write(body);
1870
+ stream.uncork();
1871
+ stream.end();
1872
+ request.onBodySent(body);
1873
+ request.onRequestSent();
1874
+ } else if (util.isBlobLike(body)) {
1875
+ if (typeof body.stream === 'function') {
1876
+ writeIterable({
1877
+ client,
1878
+ request,
1879
+ contentLength,
1880
+ h2stream: stream,
1881
+ expectsPayload,
1882
+ body: body.stream(),
1883
+ socket: client[kSocket],
1884
+ header: ''
1885
+ });
1886
+ } else {
1887
+ writeBlob({
1888
+ body,
1889
+ client,
1890
+ request,
1891
+ contentLength,
1892
+ expectsPayload,
1893
+ h2stream: stream,
1894
+ header: '',
1895
+ socket: client[kSocket]
1896
+ });
1897
+ }
1898
+ } else if (util.isStream(body)) {
1899
+ writeStream({
1900
+ body,
1901
+ client,
1902
+ request,
1903
+ contentLength,
1904
+ expectsPayload,
1905
+ socket: client[kSocket],
1906
+ h2stream: stream,
1907
+ header: ''
1908
+ });
1909
+ } else if (util.isIterable(body)) {
1910
+ writeIterable({
1911
+ body,
1912
+ client,
1913
+ request,
1914
+ contentLength,
1915
+ expectsPayload,
1916
+ header: '',
1917
+ h2stream: stream,
1918
+ socket: client[kSocket]
1919
+ });
1920
+ } else {
1921
+ assert(false);
1922
+ }
1923
+ }
1924
+ }
1925
+
1926
+ function writeStream ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
1927
+ assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined');
1928
+
1929
+ if (client[kHTTPConnVersion] === 'h2') {
1930
+ // For HTTP/2, is enough to pipe the stream
1931
+ const pipe = pipeline(
1932
+ body,
1933
+ h2stream,
1934
+ (err) => {
1935
+ if (err) {
1936
+ util.destroy(body, err);
1937
+ util.destroy(h2stream, err);
1938
+ } else {
1939
+ request.onRequestSent();
1940
+ }
1941
+ }
1942
+ );
1943
+
1944
+ pipe.on('data', onPipeData);
1945
+ pipe.once('end', () => {
1946
+ pipe.removeListener('data', onPipeData);
1947
+ util.destroy(pipe);
1948
+ });
1949
+
1950
+ function onPipeData (chunk) {
1951
+ request.onBodySent(chunk);
1952
+ }
1953
+
1954
+ return
1955
+ }
1956
+
1957
+ let finished = false;
1958
+
1959
+ const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header });
1960
+
1961
+ const onData = function (chunk) {
1962
+ if (finished) {
1963
+ return
1964
+ }
1965
+
1966
+ try {
1967
+ if (!writer.write(chunk) && this.pause) {
1968
+ this.pause();
1969
+ }
1970
+ } catch (err) {
1971
+ util.destroy(this, err);
1972
+ }
1973
+ };
1974
+ const onDrain = function () {
1975
+ if (finished) {
1976
+ return
1977
+ }
1978
+
1979
+ if (body.resume) {
1980
+ body.resume();
1981
+ }
1982
+ };
1983
+ const onAbort = function () {
1984
+ if (finished) {
1985
+ return
1986
+ }
1987
+ const err = new RequestAbortedError();
1988
+ queueMicrotask(() => onFinished(err));
1989
+ };
1990
+ const onFinished = function (err) {
1991
+ if (finished) {
1992
+ return
1993
+ }
1994
+
1995
+ finished = true;
1996
+
1997
+ assert(socket.destroyed || (socket[kWriting] && client[kRunning] <= 1));
1998
+
1999
+ socket
2000
+ .off('drain', onDrain)
2001
+ .off('error', onFinished);
2002
+
2003
+ body
2004
+ .removeListener('data', onData)
2005
+ .removeListener('end', onFinished)
2006
+ .removeListener('error', onFinished)
2007
+ .removeListener('close', onAbort);
2008
+
2009
+ if (!err) {
2010
+ try {
2011
+ writer.end();
2012
+ } catch (er) {
2013
+ err = er;
2014
+ }
2015
+ }
2016
+
2017
+ writer.destroy(err);
2018
+
2019
+ if (err && (err.code !== 'UND_ERR_INFO' || err.message !== 'reset')) {
2020
+ util.destroy(body, err);
2021
+ } else {
2022
+ util.destroy(body);
2023
+ }
2024
+ };
2025
+
2026
+ body
2027
+ .on('data', onData)
2028
+ .on('end', onFinished)
2029
+ .on('error', onFinished)
2030
+ .on('close', onAbort);
2031
+
2032
+ if (body.resume) {
2033
+ body.resume();
2034
+ }
2035
+
2036
+ socket
2037
+ .on('drain', onDrain)
2038
+ .on('error', onFinished);
2039
+ }
2040
+
2041
+ async function writeBlob ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
2042
+ assert(contentLength === body.size, 'blob body must have content length');
2043
+
2044
+ const isH2 = client[kHTTPConnVersion] === 'h2';
2045
+ try {
2046
+ if (contentLength != null && contentLength !== body.size) {
2047
+ throw new RequestContentLengthMismatchError()
2048
+ }
2049
+
2050
+ const buffer = Buffer.from(await body.arrayBuffer());
2051
+
2052
+ if (isH2) {
2053
+ h2stream.cork();
2054
+ h2stream.write(buffer);
2055
+ h2stream.uncork();
2056
+ } else {
2057
+ socket.cork();
2058
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1');
2059
+ socket.write(buffer);
2060
+ socket.uncork();
2061
+ }
2062
+
2063
+ request.onBodySent(buffer);
2064
+ request.onRequestSent();
2065
+
2066
+ if (!expectsPayload) {
2067
+ socket[kReset] = true;
2068
+ }
2069
+
2070
+ resume(client);
2071
+ } catch (err) {
2072
+ util.destroy(isH2 ? h2stream : socket, err);
2073
+ }
2074
+ }
2075
+
2076
+ async function writeIterable ({ h2stream, body, client, request, socket, contentLength, header, expectsPayload }) {
2077
+ assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined');
2078
+
2079
+ let callback = null;
2080
+ function onDrain () {
2081
+ if (callback) {
2082
+ const cb = callback;
2083
+ callback = null;
2084
+ cb();
2085
+ }
2086
+ }
2087
+
2088
+ const waitForDrain = () => new Promise((resolve, reject) => {
2089
+ assert(callback === null);
2090
+
2091
+ if (socket[kError]) {
2092
+ reject(socket[kError]);
2093
+ } else {
2094
+ callback = resolve;
2095
+ }
2096
+ });
2097
+
2098
+ if (client[kHTTPConnVersion] === 'h2') {
2099
+ h2stream
2100
+ .on('close', onDrain)
2101
+ .on('drain', onDrain);
2102
+
2103
+ try {
2104
+ // It's up to the user to somehow abort the async iterable.
2105
+ for await (const chunk of body) {
2106
+ if (socket[kError]) {
2107
+ throw socket[kError]
2108
+ }
2109
+
2110
+ const res = h2stream.write(chunk);
2111
+ request.onBodySent(chunk);
2112
+ if (!res) {
2113
+ await waitForDrain();
2114
+ }
2115
+ }
2116
+ } catch (err) {
2117
+ h2stream.destroy(err);
2118
+ } finally {
2119
+ request.onRequestSent();
2120
+ h2stream.end();
2121
+ h2stream
2122
+ .off('close', onDrain)
2123
+ .off('drain', onDrain);
2124
+ }
2125
+
2126
+ return
2127
+ }
2128
+
2129
+ socket
2130
+ .on('close', onDrain)
2131
+ .on('drain', onDrain);
2132
+
2133
+ const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header });
2134
+ try {
2135
+ // It's up to the user to somehow abort the async iterable.
2136
+ for await (const chunk of body) {
2137
+ if (socket[kError]) {
2138
+ throw socket[kError]
2139
+ }
2140
+
2141
+ if (!writer.write(chunk)) {
2142
+ await waitForDrain();
2143
+ }
2144
+ }
2145
+
2146
+ writer.end();
2147
+ } catch (err) {
2148
+ writer.destroy(err);
2149
+ } finally {
2150
+ socket
2151
+ .off('close', onDrain)
2152
+ .off('drain', onDrain);
2153
+ }
2154
+ }
2155
+
2156
+ class AsyncWriter {
2157
+ constructor ({ socket, request, contentLength, client, expectsPayload, header }) {
2158
+ this.socket = socket;
2159
+ this.request = request;
2160
+ this.contentLength = contentLength;
2161
+ this.client = client;
2162
+ this.bytesWritten = 0;
2163
+ this.expectsPayload = expectsPayload;
2164
+ this.header = header;
2165
+
2166
+ socket[kWriting] = true;
2167
+ }
2168
+
2169
+ write (chunk) {
2170
+ const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this;
2171
+
2172
+ if (socket[kError]) {
2173
+ throw socket[kError]
2174
+ }
2175
+
2176
+ if (socket.destroyed) {
2177
+ return false
2178
+ }
2179
+
2180
+ const len = Buffer.byteLength(chunk);
2181
+ if (!len) {
2182
+ return true
2183
+ }
2184
+
2185
+ // We should defer writing chunks.
2186
+ if (contentLength !== null && bytesWritten + len > contentLength) {
2187
+ if (client[kStrictContentLength]) {
2188
+ throw new RequestContentLengthMismatchError()
2189
+ }
2190
+
2191
+ process.emitWarning(new RequestContentLengthMismatchError());
2192
+ }
2193
+
2194
+ socket.cork();
2195
+
2196
+ if (bytesWritten === 0) {
2197
+ if (!expectsPayload) {
2198
+ socket[kReset] = true;
2199
+ }
2200
+
2201
+ if (contentLength === null) {
2202
+ socket.write(`${header}transfer-encoding: chunked\r\n`, 'latin1');
2203
+ } else {
2204
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1');
2205
+ }
2206
+ }
2207
+
2208
+ if (contentLength === null) {
2209
+ socket.write(`\r\n${len.toString(16)}\r\n`, 'latin1');
2210
+ }
2211
+
2212
+ this.bytesWritten += len;
2213
+
2214
+ const ret = socket.write(chunk);
2215
+
2216
+ socket.uncork();
2217
+
2218
+ request.onBodySent(chunk);
2219
+
2220
+ if (!ret) {
2221
+ if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
2222
+ // istanbul ignore else: only for jest
2223
+ if (socket[kParser].timeout.refresh) {
2224
+ socket[kParser].timeout.refresh();
2225
+ }
2226
+ }
2227
+ }
2228
+
2229
+ return ret
2230
+ }
2231
+
2232
+ end () {
2233
+ const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this;
2234
+ request.onRequestSent();
2235
+
2236
+ socket[kWriting] = false;
2237
+
2238
+ if (socket[kError]) {
2239
+ throw socket[kError]
2240
+ }
2241
+
2242
+ if (socket.destroyed) {
2243
+ return
2244
+ }
2245
+
2246
+ if (bytesWritten === 0) {
2247
+ if (expectsPayload) {
2248
+ // https://tools.ietf.org/html/rfc7230#section-3.3.2
2249
+ // A user agent SHOULD send a Content-Length in a request message when
2250
+ // no Transfer-Encoding is sent and the request method defines a meaning
2251
+ // for an enclosed payload body.
2252
+
2253
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1');
2254
+ } else {
2255
+ socket.write(`${header}\r\n`, 'latin1');
2256
+ }
2257
+ } else if (contentLength === null) {
2258
+ socket.write('\r\n0\r\n\r\n', 'latin1');
2259
+ }
2260
+
2261
+ if (contentLength !== null && bytesWritten !== contentLength) {
2262
+ if (client[kStrictContentLength]) {
2263
+ throw new RequestContentLengthMismatchError()
2264
+ } else {
2265
+ process.emitWarning(new RequestContentLengthMismatchError());
2266
+ }
2267
+ }
2268
+
2269
+ if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
2270
+ // istanbul ignore else: only for jest
2271
+ if (socket[kParser].timeout.refresh) {
2272
+ socket[kParser].timeout.refresh();
2273
+ }
2274
+ }
2275
+
2276
+ resume(client);
2277
+ }
2278
+
2279
+ destroy (err) {
2280
+ const { socket, client } = this;
2281
+
2282
+ socket[kWriting] = false;
2283
+
2284
+ if (err) {
2285
+ assert(client[kRunning] <= 1, 'pipeline should only contain this request');
2286
+ util.destroy(socket, err);
2287
+ }
2288
+ }
2289
+ }
2290
+
2291
+ function errorRequest (client, request, err) {
2292
+ try {
2293
+ request.onError(err);
2294
+ assert(request.aborted);
2295
+ } catch (err) {
2296
+ client.emit('error', err);
2297
+ }
2298
+ }
2299
+
2300
+ client = Client;
2301
+ return client;
2302
+ }
2303
+
2304
+ export { requireClient as __require };
2305
+ //# sourceMappingURL=client.js.map