@relative-ci/core 5.2.2 → 5.3.0-alpha.1

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