@pnpm/exe 11.10.0 → 11.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/{dist/node_modules/v8-compile-cache/LICENSE → LICENSE} +2 -1
  3. package/package.json +11 -11
  4. package/dist/node-gyp-bin/node-gyp +0 -6
  5. package/dist/node-gyp-bin/node-gyp.cmd +0 -5
  6. package/dist/node_modules/.package-map.json +0 -1
  7. package/dist/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
  8. package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
  9. package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
  10. package/dist/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
  11. package/dist/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
  12. package/dist/node_modules/@isaacs/fs-minipass/package.json +0 -72
  13. package/dist/node_modules/abbrev/LICENSE +0 -46
  14. package/dist/node_modules/abbrev/lib/index.js +0 -53
  15. package/dist/node_modules/abbrev/package.json +0 -41
  16. package/dist/node_modules/chownr/dist/commonjs/index.js +0 -93
  17. package/dist/node_modules/chownr/dist/commonjs/package.json +0 -3
  18. package/dist/node_modules/chownr/dist/esm/index.js +0 -85
  19. package/dist/node_modules/chownr/dist/esm/package.json +0 -3
  20. package/dist/node_modules/chownr/package.json +0 -69
  21. package/dist/node_modules/env-paths/index.js +0 -74
  22. package/dist/node_modules/env-paths/license +0 -9
  23. package/dist/node_modules/env-paths/package.json +0 -45
  24. package/dist/node_modules/exponential-backoff/LICENSE +0 -202
  25. package/dist/node_modules/exponential-backoff/dist/backoff.js +0 -124
  26. package/dist/node_modules/exponential-backoff/dist/delay/always/always.delay.js +0 -25
  27. package/dist/node_modules/exponential-backoff/dist/delay/delay.base.js +0 -45
  28. package/dist/node_modules/exponential-backoff/dist/delay/delay.factory.js +0 -17
  29. package/dist/node_modules/exponential-backoff/dist/delay/delay.interface.js +0 -3
  30. package/dist/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js +0 -82
  31. package/dist/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js +0 -8
  32. package/dist/node_modules/exponential-backoff/dist/jitter/jitter.factory.js +0 -15
  33. package/dist/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js +0 -7
  34. package/dist/node_modules/exponential-backoff/dist/options.js +0 -31
  35. package/dist/node_modules/exponential-backoff/package.json +0 -62
  36. package/dist/node_modules/fdir/LICENSE +0 -7
  37. package/dist/node_modules/fdir/dist/index.cjs +0 -588
  38. package/dist/node_modules/fdir/dist/index.d.cts +0 -155
  39. package/dist/node_modules/fdir/dist/index.d.mts +0 -155
  40. package/dist/node_modules/fdir/dist/index.mjs +0 -570
  41. package/dist/node_modules/fdir/package.json +0 -103
  42. package/dist/node_modules/graceful-fs/LICENSE +0 -15
  43. package/dist/node_modules/graceful-fs/clone.js +0 -23
  44. package/dist/node_modules/graceful-fs/graceful-fs.js +0 -448
  45. package/dist/node_modules/graceful-fs/legacy-streams.js +0 -118
  46. package/dist/node_modules/graceful-fs/package.json +0 -53
  47. package/dist/node_modules/graceful-fs/polyfills.js +0 -355
  48. package/dist/node_modules/isexe/dist/commonjs/index.js +0 -56
  49. package/dist/node_modules/isexe/dist/commonjs/index.min.js +0 -2
  50. package/dist/node_modules/isexe/dist/commonjs/options.js +0 -3
  51. package/dist/node_modules/isexe/dist/commonjs/package.json +0 -3
  52. package/dist/node_modules/isexe/dist/commonjs/posix.js +0 -67
  53. package/dist/node_modules/isexe/dist/commonjs/win32.js +0 -63
  54. package/dist/node_modules/isexe/dist/esm/index.js +0 -16
  55. package/dist/node_modules/isexe/dist/esm/index.min.js +0 -2
  56. package/dist/node_modules/isexe/dist/esm/options.js +0 -2
  57. package/dist/node_modules/isexe/dist/esm/package.json +0 -3
  58. package/dist/node_modules/isexe/dist/esm/posix.js +0 -62
  59. package/dist/node_modules/isexe/dist/esm/win32.js +0 -58
  60. package/dist/node_modules/isexe/package.json +0 -78
  61. package/dist/node_modules/minipass/dist/commonjs/index.js +0 -1038
  62. package/dist/node_modules/minipass/dist/commonjs/package.json +0 -3
  63. package/dist/node_modules/minipass/dist/esm/index.js +0 -1020
  64. package/dist/node_modules/minipass/dist/esm/package.json +0 -3
  65. package/dist/node_modules/minipass/package.json +0 -77
  66. package/dist/node_modules/minizlib/LICENSE +0 -26
  67. package/dist/node_modules/minizlib/dist/commonjs/constants.js +0 -123
  68. package/dist/node_modules/minizlib/dist/commonjs/index.js +0 -416
  69. package/dist/node_modules/minizlib/dist/commonjs/package.json +0 -3
  70. package/dist/node_modules/minizlib/dist/esm/constants.js +0 -117
  71. package/dist/node_modules/minizlib/dist/esm/index.js +0 -363
  72. package/dist/node_modules/minizlib/dist/esm/package.json +0 -3
  73. package/dist/node_modules/minizlib/package.json +0 -80
  74. package/dist/node_modules/node-gyp/.release-please-manifest.json +0 -3
  75. package/dist/node_modules/node-gyp/LICENSE +0 -24
  76. package/dist/node_modules/node-gyp/addon.gypi +0 -204
  77. package/dist/node_modules/node-gyp/bin/node-gyp.js +0 -145
  78. package/dist/node_modules/node-gyp/eslint.config.js +0 -3
  79. package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  80. package/dist/node_modules/node-gyp/gyp/LICENSE +0 -28
  81. package/dist/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  82. package/dist/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  83. package/dist/node_modules/node-gyp/gyp/gyp +0 -8
  84. package/dist/node_modules/node-gyp/gyp/gyp.bat +0 -5
  85. package/dist/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  86. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  87. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  88. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1283
  89. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1545
  90. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  91. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -152
  92. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -270
  93. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -607
  94. package/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -706
  95. package/dist/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -725
  96. package/dist/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -186
  97. package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -170
  98. package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  99. package/dist/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  100. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  101. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -805
  102. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1169
  103. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1316
  104. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -128
  105. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -104
  106. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  107. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -88
  108. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -55
  109. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2755
  110. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3970
  111. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  112. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2957
  113. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -77
  114. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1389
  115. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -26
  116. package/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3097
  117. package/dist/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -99
  118. package/dist/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -765
  119. package/dist/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1255
  120. package/dist/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  121. package/dist/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  122. package/dist/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -371
  123. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1936
  124. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -54
  125. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -301
  126. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3180
  127. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -64
  128. package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  129. package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  130. package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  131. package/dist/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  132. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -107
  133. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  134. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  135. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  136. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  137. package/dist/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  138. package/dist/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -251
  139. package/dist/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -807
  140. package/dist/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  141. package/dist/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  142. package/dist/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  143. package/dist/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -541
  144. package/dist/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  145. package/dist/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  146. package/dist/node_modules/node-gyp/gyp/pyproject.toml +0 -116
  147. package/dist/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  148. package/dist/node_modules/node-gyp/gyp/test_gyp.py +0 -260
  149. package/dist/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  150. package/dist/node_modules/node-gyp/lib/build.js +0 -230
  151. package/dist/node_modules/node-gyp/lib/clean.js +0 -15
  152. package/dist/node_modules/node-gyp/lib/configure.js +0 -328
  153. package/dist/node_modules/node-gyp/lib/create-config-gypi.js +0 -153
  154. package/dist/node_modules/node-gyp/lib/download.js +0 -86
  155. package/dist/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  156. package/dist/node_modules/node-gyp/lib/find-python.js +0 -304
  157. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +0 -606
  158. package/dist/node_modules/node-gyp/lib/install.js +0 -411
  159. package/dist/node_modules/node-gyp/lib/list.js +0 -26
  160. package/dist/node_modules/node-gyp/lib/log.js +0 -168
  161. package/dist/node_modules/node-gyp/lib/node-gyp.js +0 -199
  162. package/dist/node_modules/node-gyp/lib/process-release.js +0 -144
  163. package/dist/node_modules/node-gyp/lib/rebuild.js +0 -12
  164. package/dist/node_modules/node-gyp/lib/remove.js +0 -43
  165. package/dist/node_modules/node-gyp/lib/util.js +0 -81
  166. package/dist/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  167. package/dist/node_modules/node-gyp/package.json +0 -52
  168. package/dist/node_modules/node-gyp/release-please-config.json +0 -40
  169. package/dist/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -41
  170. package/dist/node_modules/nopt/LICENSE +0 -15
  171. package/dist/node_modules/nopt/bin/nopt.js +0 -29
  172. package/dist/node_modules/nopt/lib/debug.js +0 -5
  173. package/dist/node_modules/nopt/lib/nopt-lib.js +0 -514
  174. package/dist/node_modules/nopt/lib/nopt.js +0 -34
  175. package/dist/node_modules/nopt/lib/type-defs.js +0 -91
  176. package/dist/node_modules/nopt/package.json +0 -52
  177. package/dist/node_modules/picomatch/LICENSE +0 -21
  178. package/dist/node_modules/picomatch/index.js +0 -17
  179. package/dist/node_modules/picomatch/lib/constants.js +0 -184
  180. package/dist/node_modules/picomatch/lib/parse.js +0 -1416
  181. package/dist/node_modules/picomatch/lib/picomatch.js +0 -361
  182. package/dist/node_modules/picomatch/lib/scan.js +0 -391
  183. package/dist/node_modules/picomatch/lib/utils.js +0 -72
  184. package/dist/node_modules/picomatch/package.json +0 -83
  185. package/dist/node_modules/picomatch/posix.js +0 -3
  186. package/dist/node_modules/proc-log/LICENSE +0 -15
  187. package/dist/node_modules/proc-log/lib/index.js +0 -158
  188. package/dist/node_modules/proc-log/package.json +0 -46
  189. package/dist/node_modules/semver/LICENSE +0 -15
  190. package/dist/node_modules/semver/bin/semver.js +0 -195
  191. package/dist/node_modules/semver/classes/comparator.js +0 -143
  192. package/dist/node_modules/semver/classes/index.js +0 -7
  193. package/dist/node_modules/semver/classes/range.js +0 -577
  194. package/dist/node_modules/semver/classes/semver.js +0 -350
  195. package/dist/node_modules/semver/functions/clean.js +0 -8
  196. package/dist/node_modules/semver/functions/cmp.js +0 -54
  197. package/dist/node_modules/semver/functions/coerce.js +0 -62
  198. package/dist/node_modules/semver/functions/compare-build.js +0 -9
  199. package/dist/node_modules/semver/functions/compare-loose.js +0 -5
  200. package/dist/node_modules/semver/functions/compare.js +0 -7
  201. package/dist/node_modules/semver/functions/diff.js +0 -60
  202. package/dist/node_modules/semver/functions/eq.js +0 -5
  203. package/dist/node_modules/semver/functions/gt.js +0 -5
  204. package/dist/node_modules/semver/functions/gte.js +0 -5
  205. package/dist/node_modules/semver/functions/inc.js +0 -21
  206. package/dist/node_modules/semver/functions/lt.js +0 -5
  207. package/dist/node_modules/semver/functions/lte.js +0 -5
  208. package/dist/node_modules/semver/functions/major.js +0 -5
  209. package/dist/node_modules/semver/functions/minor.js +0 -5
  210. package/dist/node_modules/semver/functions/neq.js +0 -5
  211. package/dist/node_modules/semver/functions/parse.js +0 -18
  212. package/dist/node_modules/semver/functions/patch.js +0 -5
  213. package/dist/node_modules/semver/functions/prerelease.js +0 -8
  214. package/dist/node_modules/semver/functions/rcompare.js +0 -5
  215. package/dist/node_modules/semver/functions/rsort.js +0 -5
  216. package/dist/node_modules/semver/functions/satisfies.js +0 -12
  217. package/dist/node_modules/semver/functions/sort.js +0 -5
  218. package/dist/node_modules/semver/functions/truncate.js +0 -48
  219. package/dist/node_modules/semver/functions/valid.js +0 -8
  220. package/dist/node_modules/semver/index.js +0 -93
  221. package/dist/node_modules/semver/internal/constants.js +0 -37
  222. package/dist/node_modules/semver/internal/debug.js +0 -11
  223. package/dist/node_modules/semver/internal/identifiers.js +0 -29
  224. package/dist/node_modules/semver/internal/lrucache.js +0 -42
  225. package/dist/node_modules/semver/internal/parse-options.js +0 -17
  226. package/dist/node_modules/semver/internal/re.js +0 -223
  227. package/dist/node_modules/semver/package.json +0 -78
  228. package/dist/node_modules/semver/preload.js +0 -4
  229. package/dist/node_modules/semver/range.bnf +0 -17
  230. package/dist/node_modules/semver/ranges/gtr.js +0 -6
  231. package/dist/node_modules/semver/ranges/intersects.js +0 -9
  232. package/dist/node_modules/semver/ranges/ltr.js +0 -6
  233. package/dist/node_modules/semver/ranges/max-satisfying.js +0 -27
  234. package/dist/node_modules/semver/ranges/min-satisfying.js +0 -26
  235. package/dist/node_modules/semver/ranges/min-version.js +0 -63
  236. package/dist/node_modules/semver/ranges/outside.js +0 -82
  237. package/dist/node_modules/semver/ranges/simplify.js +0 -49
  238. package/dist/node_modules/semver/ranges/subset.js +0 -249
  239. package/dist/node_modules/semver/ranges/to-comparators.js +0 -10
  240. package/dist/node_modules/semver/ranges/valid.js +0 -13
  241. package/dist/node_modules/tar/dist/commonjs/create.js +0 -82
  242. package/dist/node_modules/tar/dist/commonjs/cwd-error.js +0 -18
  243. package/dist/node_modules/tar/dist/commonjs/extract.js +0 -88
  244. package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
  245. package/dist/node_modules/tar/dist/commonjs/header.js +0 -348
  246. package/dist/node_modules/tar/dist/commonjs/index.js +0 -64
  247. package/dist/node_modules/tar/dist/commonjs/index.min.js +0 -4
  248. package/dist/node_modules/tar/dist/commonjs/large-numbers.js +0 -99
  249. package/dist/node_modules/tar/dist/commonjs/list.js +0 -145
  250. package/dist/node_modules/tar/dist/commonjs/make-command.js +0 -52
  251. package/dist/node_modules/tar/dist/commonjs/mkdir.js +0 -187
  252. package/dist/node_modules/tar/dist/commonjs/mode-fix.js +0 -29
  253. package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +0 -38
  254. package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
  255. package/dist/node_modules/tar/dist/commonjs/options.js +0 -66
  256. package/dist/node_modules/tar/dist/commonjs/pack.js +0 -544
  257. package/dist/node_modules/tar/dist/commonjs/package.json +0 -3
  258. package/dist/node_modules/tar/dist/commonjs/parse.js +0 -645
  259. package/dist/node_modules/tar/dist/commonjs/path-reservations.js +0 -170
  260. package/dist/node_modules/tar/dist/commonjs/pax.js +0 -182
  261. package/dist/node_modules/tar/dist/commonjs/process-umask.js +0 -7
  262. package/dist/node_modules/tar/dist/commonjs/read-entry.js +0 -136
  263. package/dist/node_modules/tar/dist/commonjs/replace.js +0 -227
  264. package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +0 -29
  265. package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +0 -18
  266. package/dist/node_modules/tar/dist/commonjs/symlink-error.js +0 -19
  267. package/dist/node_modules/tar/dist/commonjs/types.js +0 -70
  268. package/dist/node_modules/tar/dist/commonjs/unpack.js +0 -932
  269. package/dist/node_modules/tar/dist/commonjs/update.js +0 -33
  270. package/dist/node_modules/tar/dist/commonjs/warn-method.js +0 -31
  271. package/dist/node_modules/tar/dist/commonjs/winchars.js +0 -14
  272. package/dist/node_modules/tar/dist/commonjs/write-entry.js +0 -698
  273. package/dist/node_modules/tar/dist/esm/create.js +0 -76
  274. package/dist/node_modules/tar/dist/esm/cwd-error.js +0 -14
  275. package/dist/node_modules/tar/dist/esm/extract.js +0 -49
  276. package/dist/node_modules/tar/dist/esm/get-write-flag.js +0 -26
  277. package/dist/node_modules/tar/dist/esm/header.js +0 -311
  278. package/dist/node_modules/tar/dist/esm/index.js +0 -20
  279. package/dist/node_modules/tar/dist/esm/index.min.js +0 -4
  280. package/dist/node_modules/tar/dist/esm/large-numbers.js +0 -94
  281. package/dist/node_modules/tar/dist/esm/list.js +0 -105
  282. package/dist/node_modules/tar/dist/esm/make-command.js +0 -48
  283. package/dist/node_modules/tar/dist/esm/mkdir.js +0 -179
  284. package/dist/node_modules/tar/dist/esm/mode-fix.js +0 -25
  285. package/dist/node_modules/tar/dist/esm/normalize-unicode.js +0 -34
  286. package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
  287. package/dist/node_modules/tar/dist/esm/options.js +0 -54
  288. package/dist/node_modules/tar/dist/esm/pack.js +0 -502
  289. package/dist/node_modules/tar/dist/esm/package.json +0 -3
  290. package/dist/node_modules/tar/dist/esm/parse.js +0 -641
  291. package/dist/node_modules/tar/dist/esm/path-reservations.js +0 -166
  292. package/dist/node_modules/tar/dist/esm/pax.js +0 -178
  293. package/dist/node_modules/tar/dist/esm/process-umask.js +0 -3
  294. package/dist/node_modules/tar/dist/esm/read-entry.js +0 -132
  295. package/dist/node_modules/tar/dist/esm/replace.js +0 -221
  296. package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +0 -25
  297. package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +0 -14
  298. package/dist/node_modules/tar/dist/esm/symlink-error.js +0 -15
  299. package/dist/node_modules/tar/dist/esm/types.js +0 -65
  300. package/dist/node_modules/tar/dist/esm/unpack.js +0 -891
  301. package/dist/node_modules/tar/dist/esm/update.js +0 -30
  302. package/dist/node_modules/tar/dist/esm/warn-method.js +0 -27
  303. package/dist/node_modules/tar/dist/esm/winchars.js +0 -9
  304. package/dist/node_modules/tar/dist/esm/write-entry.js +0 -656
  305. package/dist/node_modules/tar/package.json +0 -298
  306. package/dist/node_modules/tinyglobby/LICENSE +0 -21
  307. package/dist/node_modules/tinyglobby/dist/index.cjs +0 -335
  308. package/dist/node_modules/tinyglobby/dist/index.d.cts +0 -148
  309. package/dist/node_modules/tinyglobby/dist/index.d.mts +0 -148
  310. package/dist/node_modules/tinyglobby/dist/index.mjs +0 -307
  311. package/dist/node_modules/tinyglobby/package.json +0 -70
  312. package/dist/node_modules/undici/LICENSE +0 -21
  313. package/dist/node_modules/undici/index-fetch.js +0 -35
  314. package/dist/node_modules/undici/index.js +0 -169
  315. package/dist/node_modules/undici/lib/api/abort-signal.js +0 -57
  316. package/dist/node_modules/undici/lib/api/api-connect.js +0 -108
  317. package/dist/node_modules/undici/lib/api/api-pipeline.js +0 -251
  318. package/dist/node_modules/undici/lib/api/api-request.js +0 -214
  319. package/dist/node_modules/undici/lib/api/api-stream.js +0 -220
  320. package/dist/node_modules/undici/lib/api/api-upgrade.js +0 -108
  321. package/dist/node_modules/undici/lib/api/index.js +0 -7
  322. package/dist/node_modules/undici/lib/api/readable.js +0 -385
  323. package/dist/node_modules/undici/lib/api/util.js +0 -93
  324. package/dist/node_modules/undici/lib/core/connect.js +0 -240
  325. package/dist/node_modules/undici/lib/core/constants.js +0 -118
  326. package/dist/node_modules/undici/lib/core/diagnostics.js +0 -202
  327. package/dist/node_modules/undici/lib/core/errors.js +0 -425
  328. package/dist/node_modules/undici/lib/core/request.js +0 -405
  329. package/dist/node_modules/undici/lib/core/symbols.js +0 -67
  330. package/dist/node_modules/undici/lib/core/tree.js +0 -152
  331. package/dist/node_modules/undici/lib/core/util.js +0 -719
  332. package/dist/node_modules/undici/lib/dispatcher/agent.js +0 -129
  333. package/dist/node_modules/undici/lib/dispatcher/balanced-pool.js +0 -209
  334. package/dist/node_modules/undici/lib/dispatcher/client-h1.js +0 -1487
  335. package/dist/node_modules/undici/lib/dispatcher/client-h2.js +0 -744
  336. package/dist/node_modules/undici/lib/dispatcher/client.js +0 -623
  337. package/dist/node_modules/undici/lib/dispatcher/dispatcher-base.js +0 -199
  338. package/dist/node_modules/undici/lib/dispatcher/dispatcher.js +0 -65
  339. package/dist/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +0 -160
  340. package/dist/node_modules/undici/lib/dispatcher/fixed-queue.js +0 -117
  341. package/dist/node_modules/undici/lib/dispatcher/pool-base.js +0 -194
  342. package/dist/node_modules/undici/lib/dispatcher/pool-stats.js +0 -34
  343. package/dist/node_modules/undici/lib/dispatcher/pool.js +0 -107
  344. package/dist/node_modules/undici/lib/dispatcher/proxy-agent.js +0 -274
  345. package/dist/node_modules/undici/lib/dispatcher/retry-agent.js +0 -35
  346. package/dist/node_modules/undici/lib/global.js +0 -32
  347. package/dist/node_modules/undici/lib/handler/decorator-handler.js +0 -44
  348. package/dist/node_modules/undici/lib/handler/redirect-handler.js +0 -232
  349. package/dist/node_modules/undici/lib/handler/retry-handler.js +0 -374
  350. package/dist/node_modules/undici/lib/interceptor/dns.js +0 -375
  351. package/dist/node_modules/undici/lib/interceptor/dump.js +0 -123
  352. package/dist/node_modules/undici/lib/interceptor/redirect-interceptor.js +0 -21
  353. package/dist/node_modules/undici/lib/interceptor/redirect.js +0 -24
  354. package/dist/node_modules/undici/lib/interceptor/response-error.js +0 -86
  355. package/dist/node_modules/undici/lib/interceptor/retry.js +0 -19
  356. package/dist/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  357. package/dist/node_modules/undici/lib/llhttp/constants.js +0 -278
  358. package/dist/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -5
  359. package/dist/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -5
  360. package/dist/node_modules/undici/lib/llhttp/utils.js +0 -15
  361. package/dist/node_modules/undici/lib/mock/mock-agent.js +0 -160
  362. package/dist/node_modules/undici/lib/mock/mock-client.js +0 -59
  363. package/dist/node_modules/undici/lib/mock/mock-errors.js +0 -28
  364. package/dist/node_modules/undici/lib/mock/mock-interceptor.js +0 -207
  365. package/dist/node_modules/undici/lib/mock/mock-pool.js +0 -59
  366. package/dist/node_modules/undici/lib/mock/mock-symbols.js +0 -23
  367. package/dist/node_modules/undici/lib/mock/mock-utils.js +0 -367
  368. package/dist/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -43
  369. package/dist/node_modules/undici/lib/mock/pluralizer.js +0 -29
  370. package/dist/node_modules/undici/lib/util/timers.js +0 -423
  371. package/dist/node_modules/undici/lib/web/cache/cache.js +0 -859
  372. package/dist/node_modules/undici/lib/web/cache/cachestorage.js +0 -152
  373. package/dist/node_modules/undici/lib/web/cache/symbols.js +0 -5
  374. package/dist/node_modules/undici/lib/web/cache/util.js +0 -45
  375. package/dist/node_modules/undici/lib/web/cookies/constants.js +0 -12
  376. package/dist/node_modules/undici/lib/web/cookies/index.js +0 -184
  377. package/dist/node_modules/undici/lib/web/cookies/parse.js +0 -310
  378. package/dist/node_modules/undici/lib/web/cookies/util.js +0 -282
  379. package/dist/node_modules/undici/lib/web/eventsource/eventsource-stream.js +0 -398
  380. package/dist/node_modules/undici/lib/web/eventsource/eventsource.js +0 -480
  381. package/dist/node_modules/undici/lib/web/eventsource/util.js +0 -37
  382. package/dist/node_modules/undici/lib/web/fetch/LICENSE +0 -21
  383. package/dist/node_modules/undici/lib/web/fetch/body.js +0 -529
  384. package/dist/node_modules/undici/lib/web/fetch/constants.js +0 -124
  385. package/dist/node_modules/undici/lib/web/fetch/data-url.js +0 -744
  386. package/dist/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +0 -46
  387. package/dist/node_modules/undici/lib/web/fetch/file.js +0 -126
  388. package/dist/node_modules/undici/lib/web/fetch/formdata-parser.js +0 -474
  389. package/dist/node_modules/undici/lib/web/fetch/formdata.js +0 -252
  390. package/dist/node_modules/undici/lib/web/fetch/global.js +0 -40
  391. package/dist/node_modules/undici/lib/web/fetch/headers.js +0 -687
  392. package/dist/node_modules/undici/lib/web/fetch/index.js +0 -2272
  393. package/dist/node_modules/undici/lib/web/fetch/request.js +0 -1037
  394. package/dist/node_modules/undici/lib/web/fetch/response.js +0 -610
  395. package/dist/node_modules/undici/lib/web/fetch/symbols.js +0 -9
  396. package/dist/node_modules/undici/lib/web/fetch/util.js +0 -1632
  397. package/dist/node_modules/undici/lib/web/fetch/webidl.js +0 -695
  398. package/dist/node_modules/undici/lib/web/fileapi/encoding.js +0 -290
  399. package/dist/node_modules/undici/lib/web/fileapi/filereader.js +0 -344
  400. package/dist/node_modules/undici/lib/web/fileapi/progressevent.js +0 -78
  401. package/dist/node_modules/undici/lib/web/fileapi/symbols.js +0 -10
  402. package/dist/node_modules/undici/lib/web/fileapi/util.js +0 -391
  403. package/dist/node_modules/undici/lib/web/websocket/connection.js +0 -371
  404. package/dist/node_modules/undici/lib/web/websocket/constants.js +0 -66
  405. package/dist/node_modules/undici/lib/web/websocket/events.js +0 -329
  406. package/dist/node_modules/undici/lib/web/websocket/frame.js +0 -96
  407. package/dist/node_modules/undici/lib/web/websocket/permessage-deflate.js +0 -100
  408. package/dist/node_modules/undici/lib/web/websocket/receiver.js +0 -513
  409. package/dist/node_modules/undici/lib/web/websocket/sender.js +0 -104
  410. package/dist/node_modules/undici/lib/web/websocket/symbols.js +0 -12
  411. package/dist/node_modules/undici/lib/web/websocket/util.js +0 -322
  412. package/dist/node_modules/undici/lib/web/websocket/websocket.js +0 -595
  413. package/dist/node_modules/undici/package.json +0 -160
  414. package/dist/node_modules/undici/scripts/strip-comments.js +0 -8
  415. package/dist/node_modules/v8-compile-cache/package.json +0 -34
  416. package/dist/node_modules/v8-compile-cache/v8-compile-cache.js +0 -373
  417. package/dist/node_modules/which/LICENSE +0 -15
  418. package/dist/node_modules/which/bin/which.js +0 -52
  419. package/dist/node_modules/which/lib/index.js +0 -111
  420. package/dist/node_modules/which/package.json +0 -52
  421. package/dist/node_modules/yallist/dist/commonjs/index.js +0 -384
  422. package/dist/node_modules/yallist/dist/commonjs/package.json +0 -3
  423. package/dist/node_modules/yallist/dist/esm/index.js +0 -379
  424. package/dist/node_modules/yallist/dist/esm/package.json +0 -3
  425. package/dist/node_modules/yallist/package.json +0 -68
  426. package/dist/pnpm.mjs +0 -307717
  427. package/dist/pnpmrc +0 -2
  428. package/dist/templates/completion.bash +0 -31
  429. package/dist/templates/completion.fish +0 -22
  430. package/dist/templates/completion.ps1 +0 -193
  431. package/dist/templates/completion.zsh +0 -27
  432. package/dist/vendor/fastlist-0.3.0-x64.exe +0 -0
  433. package/dist/vendor/fastlist-0.3.0-x86.exe +0 -0
  434. package/dist/worker.js +0 -11938
  435. package/pn.cmd +0 -2
  436. package/pn.ps1 +0 -1
  437. package/pnpx.cmd +0 -2
  438. package/pnpx.ps1 +0 -1
  439. package/pnx.cmd +0 -2
  440. package/pnx.ps1 +0 -1
@@ -1,1487 +0,0 @@
1
- 'use strict'
2
-
3
- /* global WebAssembly */
4
-
5
- const assert = require('node:assert')
6
- const util = require('../core/util.js')
7
- const { channels } = require('../core/diagnostics.js')
8
- const timers = require('../util/timers.js')
9
- const {
10
- RequestContentLengthMismatchError,
11
- ResponseContentLengthMismatchError,
12
- RequestAbortedError,
13
- HeadersTimeoutError,
14
- HeadersOverflowError,
15
- SocketError,
16
- InformationalError,
17
- BodyTimeoutError,
18
- HTTPParserError,
19
- ResponseExceededMaxSizeError
20
- } = require('../core/errors.js')
21
- const {
22
- kUrl,
23
- kReset,
24
- kClient,
25
- kParser,
26
- kBlocking,
27
- kRunning,
28
- kPending,
29
- kSize,
30
- kWriting,
31
- kQueue,
32
- kNoRef,
33
- kKeepAliveDefaultTimeout,
34
- kHostHeader,
35
- kPendingIdx,
36
- kRunningIdx,
37
- kError,
38
- kPipelining,
39
- kSocket,
40
- kKeepAliveTimeoutValue,
41
- kMaxHeadersSize,
42
- kKeepAliveMaxTimeout,
43
- kKeepAliveTimeoutThreshold,
44
- kHeadersTimeout,
45
- kBodyTimeout,
46
- kStrictContentLength,
47
- kMaxRequests,
48
- kCounter,
49
- kMaxResponseSize,
50
- kOnError,
51
- kResume,
52
- kHTTPContext
53
- } = require('../core/symbols.js')
54
-
55
- const constants = require('../llhttp/constants.js')
56
- const EMPTY_BUF = Buffer.alloc(0)
57
- const FastBuffer = Buffer[Symbol.species]
58
- const addListener = util.addListener
59
- const removeAllListeners = util.removeAllListeners
60
- const kIdleSocketValidation = Symbol('kIdleSocketValidation')
61
- const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
62
- const kSocketUsed = Symbol('kSocketUsed')
63
-
64
- let extractBody
65
-
66
- async function lazyllhttp () {
67
- const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
68
-
69
- let mod
70
- try {
71
- mod = await WebAssembly.compile(require('../llhttp/llhttp_simd-wasm.js'))
72
- } catch (e) {
73
- /* istanbul ignore next */
74
-
75
- // We could check if the error was caused by the simd option not
76
- // being enabled, but the occurring of this other error
77
- // * https://github.com/emscripten-core/emscripten/issues/11495
78
- // got me to remove that check to avoid breaking Node 12.
79
- mod = await WebAssembly.compile(llhttpWasmData || require('../llhttp/llhttp-wasm.js'))
80
- }
81
-
82
- return await WebAssembly.instantiate(mod, {
83
- env: {
84
- /* eslint-disable camelcase */
85
-
86
- wasm_on_url: (p, at, len) => {
87
- /* istanbul ignore next */
88
- return 0
89
- },
90
- wasm_on_status: (p, at, len) => {
91
- assert(currentParser.ptr === p)
92
- const start = at - currentBufferPtr + currentBufferRef.byteOffset
93
- return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
94
- },
95
- wasm_on_message_begin: (p) => {
96
- assert(currentParser.ptr === p)
97
- return currentParser.onMessageBegin() || 0
98
- },
99
- wasm_on_header_field: (p, at, len) => {
100
- assert(currentParser.ptr === p)
101
- const start = at - currentBufferPtr + currentBufferRef.byteOffset
102
- return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
103
- },
104
- wasm_on_header_value: (p, at, len) => {
105
- assert(currentParser.ptr === p)
106
- const start = at - currentBufferPtr + currentBufferRef.byteOffset
107
- return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
108
- },
109
- wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => {
110
- assert(currentParser.ptr === p)
111
- return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0
112
- },
113
- wasm_on_body: (p, at, len) => {
114
- assert(currentParser.ptr === p)
115
- const start = at - currentBufferPtr + currentBufferRef.byteOffset
116
- return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0
117
- },
118
- wasm_on_message_complete: (p) => {
119
- assert(currentParser.ptr === p)
120
- return currentParser.onMessageComplete() || 0
121
- }
122
-
123
- /* eslint-enable camelcase */
124
- }
125
- })
126
- }
127
-
128
- let llhttpInstance = null
129
- let llhttpPromise = lazyllhttp()
130
- llhttpPromise.catch()
131
-
132
- let currentParser = null
133
- let currentBufferRef = null
134
- let currentBufferSize = 0
135
- let currentBufferPtr = null
136
-
137
- const USE_NATIVE_TIMER = 0
138
- const USE_FAST_TIMER = 1
139
-
140
- // Use fast timers for headers and body to take eventual event loop
141
- // latency into account.
142
- const TIMEOUT_HEADERS = 2 | USE_FAST_TIMER
143
- const TIMEOUT_BODY = 4 | USE_FAST_TIMER
144
-
145
- // Use native timers to ignore event loop latency for keep-alive
146
- // handling.
147
- const TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER
148
-
149
- class Parser {
150
- constructor (client, socket, { exports }) {
151
- assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0)
152
-
153
- this.llhttp = exports
154
- this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE)
155
- this.client = client
156
- this.socket = socket
157
- this.timeout = null
158
- this.timeoutValue = null
159
- this.timeoutType = null
160
- this.statusCode = null
161
- this.statusText = ''
162
- this.upgrade = false
163
- this.headers = []
164
- this.headersSize = 0
165
- this.headersMaxSize = client[kMaxHeadersSize]
166
- this.shouldKeepAlive = false
167
- this.paused = false
168
- this.resume = this.resume.bind(this)
169
-
170
- this.bytesRead = 0
171
-
172
- this.keepAlive = ''
173
- this.contentLength = ''
174
- this.connection = ''
175
- this.maxResponseSize = client[kMaxResponseSize]
176
- }
177
-
178
- setTimeout (delay, type) {
179
- // If the existing timer and the new timer are of different timer type
180
- // (fast or native) or have different delay, we need to clear the existing
181
- // timer and set a new one.
182
- if (
183
- delay !== this.timeoutValue ||
184
- (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)
185
- ) {
186
- // If a timeout is already set, clear it with clearTimeout of the fast
187
- // timer implementation, as it can clear fast and native timers.
188
- if (this.timeout) {
189
- timers.clearTimeout(this.timeout)
190
- this.timeout = null
191
- }
192
-
193
- if (delay) {
194
- if (type & USE_FAST_TIMER) {
195
- this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this))
196
- } else {
197
- this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this))
198
- this.timeout.unref()
199
- }
200
- }
201
-
202
- this.timeoutValue = delay
203
- } else if (this.timeout) {
204
- // istanbul ignore else: only for jest
205
- if (this.timeout.refresh) {
206
- this.timeout.refresh()
207
- }
208
- }
209
-
210
- this.timeoutType = type
211
- }
212
-
213
- resume () {
214
- if (this.socket.destroyed || !this.paused) {
215
- return
216
- }
217
-
218
- assert(this.ptr != null)
219
- assert(currentParser == null)
220
-
221
- this.llhttp.llhttp_resume(this.ptr)
222
-
223
- assert(this.timeoutType === TIMEOUT_BODY)
224
- if (this.timeout) {
225
- // istanbul ignore else: only for jest
226
- if (this.timeout.refresh) {
227
- this.timeout.refresh()
228
- }
229
- }
230
-
231
- this.paused = false
232
- this.execute(this.socket.read() || EMPTY_BUF) // Flush parser.
233
- this.readMore()
234
- }
235
-
236
- readMore () {
237
- while (!this.paused && this.ptr) {
238
- const chunk = this.socket.read()
239
- if (chunk === null) {
240
- break
241
- }
242
- this.execute(chunk)
243
- }
244
- }
245
-
246
- execute (data) {
247
- assert(this.ptr != null)
248
- assert(currentParser == null)
249
- assert(!this.paused)
250
-
251
- const { socket, llhttp } = this
252
-
253
- if (data.length > currentBufferSize) {
254
- if (currentBufferPtr) {
255
- llhttp.free(currentBufferPtr)
256
- }
257
- currentBufferSize = Math.ceil(data.length / 4096) * 4096
258
- currentBufferPtr = llhttp.malloc(currentBufferSize)
259
- }
260
-
261
- new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize).set(data)
262
-
263
- // Call `execute` on the wasm parser.
264
- // We pass the `llhttp_parser` pointer address, the pointer address of buffer view data,
265
- // and finally the length of bytes to parse.
266
- // The return value is an error code or `constants.ERROR.OK`.
267
- try {
268
- let ret
269
-
270
- try {
271
- currentBufferRef = data
272
- currentParser = this
273
- ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, data.length)
274
- /* eslint-disable-next-line no-useless-catch */
275
- } catch (err) {
276
- /* istanbul ignore next: difficult to make a test case for */
277
- throw err
278
- } finally {
279
- currentParser = null
280
- currentBufferRef = null
281
- }
282
-
283
- const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
284
-
285
- if (ret !== constants.ERROR.OK) {
286
- const body = data.subarray(offset)
287
-
288
- if (ret === constants.ERROR.PAUSED_UPGRADE) {
289
- this.onUpgrade(body)
290
- } else if (ret === constants.ERROR.PAUSED) {
291
- this.paused = true
292
- socket.unshift(body)
293
- } else {
294
- throw this.createError(ret, body)
295
- }
296
- }
297
- } catch (err) {
298
- util.destroy(socket, err)
299
- }
300
- }
301
-
302
- finish () {
303
- assert(currentParser === null)
304
- assert(this.ptr != null)
305
- assert(!this.paused)
306
-
307
- const { llhttp } = this
308
-
309
- let ret
310
-
311
- try {
312
- currentParser = this
313
- ret = llhttp.llhttp_finish(this.ptr)
314
- } finally {
315
- currentParser = null
316
- }
317
-
318
- if (ret === constants.ERROR.OK) {
319
- return null
320
- }
321
-
322
- if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
323
- this.paused = true
324
- return null
325
- }
326
-
327
- return this.createError(ret, EMPTY_BUF)
328
- }
329
-
330
- createError (ret, data) {
331
- const { llhttp, contentLength, bytesRead } = this
332
-
333
- if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
334
- return new ResponseContentLengthMismatchError()
335
- }
336
-
337
- const ptr = llhttp.llhttp_get_error_reason(this.ptr)
338
- let message = ''
339
- if (ptr) {
340
- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
341
- message =
342
- 'Response does not match the HTTP/1.1 protocol (' +
343
- Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
344
- ')'
345
- }
346
-
347
- return new HTTPParserError(message, constants.ERROR[ret], data)
348
- }
349
-
350
- destroy () {
351
- assert(this.ptr != null)
352
- assert(currentParser == null)
353
-
354
- this.llhttp.llhttp_free(this.ptr)
355
- this.ptr = null
356
-
357
- this.timeout && timers.clearTimeout(this.timeout)
358
- this.timeout = null
359
- this.timeoutValue = null
360
- this.timeoutType = null
361
-
362
- this.paused = false
363
- }
364
-
365
- onStatus (buf) {
366
- this.statusText = buf.toString()
367
- }
368
-
369
- onMessageBegin () {
370
- const { socket, client } = this
371
-
372
- /* istanbul ignore next: difficult to make a test case for */
373
- if (socket.destroyed) {
374
- return -1
375
- }
376
-
377
- if (client[kRunning] === 0) {
378
- util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
379
- return -1
380
- }
381
-
382
- const request = client[kQueue][client[kRunningIdx]]
383
- if (!request) {
384
- return -1
385
- }
386
- request.onResponseStarted()
387
- }
388
-
389
- onHeaderField (buf) {
390
- const len = this.headers.length
391
-
392
- if ((len & 1) === 0) {
393
- this.headers.push(buf)
394
- } else {
395
- this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
396
- }
397
-
398
- this.trackHeader(buf.length)
399
- }
400
-
401
- onHeaderValue (buf) {
402
- let len = this.headers.length
403
-
404
- if ((len & 1) === 1) {
405
- this.headers.push(buf)
406
- len += 1
407
- } else {
408
- this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
409
- }
410
-
411
- const key = this.headers[len - 2]
412
- if (key.length === 10) {
413
- const headerName = util.bufferToLowerCasedHeaderName(key)
414
- if (headerName === 'keep-alive') {
415
- this.keepAlive += buf.toString()
416
- } else if (headerName === 'connection') {
417
- this.connection += buf.toString()
418
- }
419
- } else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === 'content-length') {
420
- this.contentLength += buf.toString()
421
- }
422
-
423
- this.trackHeader(buf.length)
424
- }
425
-
426
- trackHeader (len) {
427
- this.headersSize += len
428
- if (this.headersSize >= this.headersMaxSize) {
429
- util.destroy(this.socket, new HeadersOverflowError())
430
- }
431
- }
432
-
433
- onUpgrade (head) {
434
- const { upgrade, client, socket, headers, statusCode } = this
435
-
436
- assert(upgrade)
437
- assert(client[kSocket] === socket)
438
- assert(!socket.destroyed)
439
- assert(!this.paused)
440
- assert((headers.length & 1) === 0)
441
-
442
- const request = client[kQueue][client[kRunningIdx]]
443
- assert(request)
444
- assert(request.upgrade || request.method === 'CONNECT')
445
-
446
- this.statusCode = null
447
- this.statusText = ''
448
- this.shouldKeepAlive = null
449
-
450
- this.headers = []
451
- this.headersSize = 0
452
-
453
- socket.unshift(head)
454
-
455
- socket[kParser].destroy()
456
- socket[kParser] = null
457
-
458
- socket[kClient] = null
459
- socket[kError] = null
460
-
461
- removeAllListeners(socket)
462
-
463
- client[kSocket] = null
464
- client[kHTTPContext] = null // TODO (fix): This is hacky...
465
- client[kQueue][client[kRunningIdx]++] = null
466
- client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
467
-
468
- try {
469
- request.onUpgrade(statusCode, headers, socket)
470
- } catch (err) {
471
- util.destroy(socket, err)
472
- }
473
-
474
- client[kResume]()
475
- }
476
-
477
- onHeadersComplete (statusCode, upgrade, shouldKeepAlive) {
478
- const { client, socket, headers, statusText } = this
479
-
480
- /* istanbul ignore next: difficult to make a test case for */
481
- if (socket.destroyed) {
482
- return -1
483
- }
484
-
485
- if (client[kRunning] === 0) {
486
- util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
487
- return -1
488
- }
489
-
490
- const request = client[kQueue][client[kRunningIdx]]
491
-
492
- /* istanbul ignore next: difficult to make a test case for */
493
- if (!request) {
494
- return -1
495
- }
496
-
497
- assert(!this.upgrade)
498
- assert(this.statusCode < 200)
499
-
500
- if (statusCode === 100) {
501
- util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
502
- return -1
503
- }
504
-
505
- /* this can only happen if server is misbehaving */
506
- if (upgrade && !request.upgrade) {
507
- util.destroy(socket, new SocketError('bad upgrade', util.getSocketInfo(socket)))
508
- return -1
509
- }
510
-
511
- assert(this.timeoutType === TIMEOUT_HEADERS)
512
-
513
- this.statusCode = statusCode
514
- this.shouldKeepAlive = (
515
- shouldKeepAlive ||
516
- // Override llhttp value which does not allow keepAlive for HEAD.
517
- (request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
518
- )
519
-
520
- if (this.statusCode >= 200) {
521
- const bodyTimeout = request.bodyTimeout != null
522
- ? request.bodyTimeout
523
- : client[kBodyTimeout]
524
- this.setTimeout(bodyTimeout, TIMEOUT_BODY)
525
- } else if (this.timeout) {
526
- // istanbul ignore else: only for jest
527
- if (this.timeout.refresh) {
528
- this.timeout.refresh()
529
- }
530
- }
531
-
532
- if (request.method === 'CONNECT') {
533
- assert(client[kRunning] === 1)
534
- this.upgrade = true
535
- return 2
536
- }
537
-
538
- if (upgrade) {
539
- assert(client[kRunning] === 1)
540
- this.upgrade = true
541
- return 2
542
- }
543
-
544
- assert((this.headers.length & 1) === 0)
545
- this.headers = []
546
- this.headersSize = 0
547
-
548
- if (this.shouldKeepAlive && client[kPipelining]) {
549
- const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null
550
-
551
- if (keepAliveTimeout != null) {
552
- const timeout = Math.min(
553
- keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
554
- client[kKeepAliveMaxTimeout]
555
- )
556
- if (timeout <= 0) {
557
- socket[kReset] = true
558
- } else {
559
- client[kKeepAliveTimeoutValue] = timeout
560
- }
561
- } else {
562
- client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout]
563
- }
564
- } else {
565
- // Stop more requests from being dispatched.
566
- socket[kReset] = true
567
- }
568
-
569
- const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
570
-
571
- if (request.aborted) {
572
- return -1
573
- }
574
-
575
- if (request.method === 'HEAD') {
576
- return 1
577
- }
578
-
579
- if (statusCode < 200) {
580
- return 1
581
- }
582
-
583
- if (socket[kBlocking]) {
584
- socket[kBlocking] = false
585
- client[kResume]()
586
- }
587
-
588
- return pause ? constants.ERROR.PAUSED : 0
589
- }
590
-
591
- onBody (buf) {
592
- const { client, socket, statusCode, maxResponseSize } = this
593
-
594
- if (socket.destroyed) {
595
- return -1
596
- }
597
-
598
- const request = client[kQueue][client[kRunningIdx]]
599
- assert(request)
600
-
601
- assert(this.timeoutType === TIMEOUT_BODY)
602
- if (this.timeout) {
603
- // istanbul ignore else: only for jest
604
- if (this.timeout.refresh) {
605
- this.timeout.refresh()
606
- }
607
- }
608
-
609
- assert(statusCode >= 200)
610
-
611
- if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
612
- util.destroy(socket, new ResponseExceededMaxSizeError())
613
- return -1
614
- }
615
-
616
- this.bytesRead += buf.length
617
-
618
- if (request.onData(buf) === false) {
619
- return constants.ERROR.PAUSED
620
- }
621
- }
622
-
623
- onMessageComplete () {
624
- const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this
625
-
626
- if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
627
- return -1
628
- }
629
-
630
- if (upgrade) {
631
- return
632
- }
633
-
634
- assert(statusCode >= 100)
635
- assert((this.headers.length & 1) === 0)
636
-
637
- const request = client[kQueue][client[kRunningIdx]]
638
- assert(request)
639
-
640
- this.statusCode = null
641
- this.statusText = ''
642
- this.bytesRead = 0
643
- this.contentLength = ''
644
- this.keepAlive = ''
645
- this.connection = ''
646
-
647
- this.headers = []
648
- this.headersSize = 0
649
-
650
- if (statusCode < 200) {
651
- return
652
- }
653
-
654
- /* istanbul ignore next: should be handled by llhttp? */
655
- if (request.method !== 'HEAD' && contentLength && bytesRead !== parseInt(contentLength, 10)) {
656
- util.destroy(socket, new ResponseContentLengthMismatchError())
657
- return -1
658
- }
659
-
660
- request.onComplete(headers)
661
-
662
- client[kQueue][client[kRunningIdx]++] = null
663
- socket[kSocketUsed] = true
664
-
665
- if (socket[kWriting]) {
666
- assert(client[kRunning] === 0)
667
- // Response completed before request.
668
- util.destroy(socket, new InformationalError('reset'))
669
- return constants.ERROR.PAUSED
670
- } else if (!shouldKeepAlive) {
671
- util.destroy(socket, new InformationalError('reset'))
672
- return constants.ERROR.PAUSED
673
- } else if (socket[kReset] && client[kRunning] === 0) {
674
- // Destroy socket once all requests have completed.
675
- // The request at the tail of the pipeline is the one
676
- // that requested reset and no further requests should
677
- // have been queued since then.
678
- util.destroy(socket, new InformationalError('reset'))
679
- return constants.ERROR.PAUSED
680
- } else if (client[kPipelining] == null || client[kPipelining] === 1) {
681
- // We must wait a full event loop cycle to reuse this socket to make sure
682
- // that non-spec compliant servers are not closing the connection even if they
683
- // said they won't.
684
- setImmediate(() => client[kResume]())
685
- } else {
686
- client[kResume]()
687
- }
688
- }
689
- }
690
-
691
- function onParserTimeout (parser) {
692
- const { socket, timeoutType, client, paused } = parser.deref()
693
-
694
- /* istanbul ignore else */
695
- if (timeoutType === TIMEOUT_HEADERS) {
696
- if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
697
- assert(!paused, 'cannot be paused while waiting for headers')
698
- util.destroy(socket, new HeadersTimeoutError())
699
- }
700
- } else if (timeoutType === TIMEOUT_BODY) {
701
- if (!paused) {
702
- util.destroy(socket, new BodyTimeoutError())
703
- }
704
- } else if (timeoutType === TIMEOUT_KEEP_ALIVE) {
705
- assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue])
706
- util.destroy(socket, new InformationalError('socket idle timeout'))
707
- }
708
- }
709
-
710
- async function connectH1 (client, socket) {
711
- client[kSocket] = socket
712
-
713
- if (!llhttpInstance) {
714
- llhttpInstance = await llhttpPromise
715
- llhttpPromise = null
716
- }
717
-
718
- socket[kNoRef] = false
719
- socket[kWriting] = false
720
- socket[kReset] = false
721
- socket[kBlocking] = false
722
- socket[kIdleSocketValidation] = 0
723
- socket[kIdleSocketValidationTimeout] = null
724
- socket[kSocketUsed] = false
725
- socket[kParser] = new Parser(client, socket, llhttpInstance)
726
-
727
- addListener(socket, 'error', function (err) {
728
- assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
729
-
730
- const parser = this[kParser]
731
-
732
- // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
733
- // to the user.
734
- if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
735
- const parserErr = parser.finish()
736
- if (parserErr) {
737
- this[kError] = parserErr
738
- this[kClient][kOnError](parserErr)
739
- }
740
- return
741
- }
742
-
743
- this[kError] = err
744
-
745
- this[kClient][kOnError](err)
746
- })
747
- addListener(socket, 'readable', function () {
748
- const parser = this[kParser]
749
-
750
- if (parser) {
751
- parser.readMore()
752
- }
753
- })
754
- addListener(socket, 'end', function () {
755
- const parser = this[kParser]
756
-
757
- if (parser.statusCode && !parser.shouldKeepAlive) {
758
- const parserErr = parser.finish()
759
- if (parserErr) {
760
- util.destroy(this, parserErr)
761
- }
762
- return
763
- }
764
-
765
- util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)))
766
- })
767
- addListener(socket, 'close', function () {
768
- const client = this[kClient]
769
- const parser = this[kParser]
770
-
771
- clearIdleSocketValidation(this)
772
-
773
- if (parser) {
774
- if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
775
- this[kError] = parser.finish() || this[kError]
776
- }
777
-
778
- this[kParser].destroy()
779
- this[kParser] = null
780
- }
781
-
782
- const err = this[kError] || new SocketError('closed', util.getSocketInfo(this))
783
-
784
- client[kSocket] = null
785
- client[kHTTPContext] = null // TODO (fix): This is hacky...
786
-
787
- if (client.destroyed) {
788
- assert(client[kPending] === 0)
789
-
790
- // Fail entire queue.
791
- const requests = client[kQueue].splice(client[kRunningIdx])
792
- for (let i = 0; i < requests.length; i++) {
793
- const request = requests[i]
794
- util.errorRequest(client, request, err)
795
- }
796
- } else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') {
797
- // Fail head of pipeline.
798
- const request = client[kQueue][client[kRunningIdx]]
799
- client[kQueue][client[kRunningIdx]++] = null
800
-
801
- util.errorRequest(client, request, err)
802
- }
803
-
804
- client[kPendingIdx] = client[kRunningIdx]
805
-
806
- assert(client[kRunning] === 0)
807
-
808
- client.emit('disconnect', client[kUrl], [client], err)
809
-
810
- client[kResume]()
811
- })
812
-
813
- let closed = false
814
- socket.on('close', () => {
815
- closed = true
816
- })
817
-
818
- return {
819
- version: 'h1',
820
- defaultPipelining: 1,
821
- write (...args) {
822
- return writeH1(client, ...args)
823
- },
824
- resume () {
825
- resumeH1(client)
826
- },
827
- destroy (err, callback) {
828
- if (closed) {
829
- queueMicrotask(callback)
830
- } else {
831
- socket.destroy(err).on('close', callback)
832
- }
833
- },
834
- get destroyed () {
835
- return socket.destroyed
836
- },
837
- busy (request) {
838
- if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
839
- return true
840
- }
841
-
842
- if (request) {
843
- if (client[kRunning] > 0 && !request.idempotent) {
844
- // Non-idempotent request cannot be retried.
845
- // Ensure that no other requests are inflight and
846
- // could cause failure.
847
- return true
848
- }
849
-
850
- if (client[kRunning] > 0 && (request.upgrade || request.method === 'CONNECT')) {
851
- // Don't dispatch an upgrade until all preceding requests have completed.
852
- // A misbehaving server might upgrade the connection before all pipelined
853
- // request has completed.
854
- return true
855
- }
856
-
857
- if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
858
- (util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))) {
859
- // Request with stream or iterator body can error while other requests
860
- // are inflight and indirectly error those as well.
861
- // Ensure this doesn't happen by waiting for inflight
862
- // to complete before dispatching.
863
-
864
- // Request with stream or iterator body cannot be retried.
865
- // Ensure that no other requests are inflight and
866
- // could cause failure.
867
- return true
868
- }
869
- }
870
-
871
- return false
872
- }
873
- }
874
- }
875
-
876
- function clearIdleSocketValidation (socket) {
877
- if (socket[kIdleSocketValidationTimeout]) {
878
- clearTimeout(socket[kIdleSocketValidationTimeout])
879
- socket[kIdleSocketValidationTimeout] = null
880
- }
881
-
882
- socket[kIdleSocketValidation] = 0
883
- }
884
-
885
- function scheduleIdleSocketValidation (client, socket) {
886
- socket[kIdleSocketValidation] = 1
887
- socket[kIdleSocketValidationTimeout] = setTimeout(() => {
888
- socket[kIdleSocketValidationTimeout] = null
889
- socket[kIdleSocketValidation] = 2
890
-
891
- if (client[kSocket] === socket && !socket.destroyed) {
892
- client[kResume]()
893
- }
894
- }, 0)
895
- socket[kIdleSocketValidationTimeout].unref?.()
896
- }
897
-
898
- /**
899
- * @param {import('./client.js')} client
900
- */
901
- function resumeH1 (client) {
902
- const socket = client[kSocket]
903
-
904
- if (socket && !socket.destroyed) {
905
- if (client[kSize] === 0) {
906
- if (!socket[kNoRef] && socket.unref) {
907
- socket.unref()
908
- socket[kNoRef] = true
909
- }
910
- } else if (socket[kNoRef] && socket.ref) {
911
- socket.ref()
912
- socket[kNoRef] = false
913
- }
914
-
915
- if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
916
- if (socket[kIdleSocketValidation] === 0) {
917
- scheduleIdleSocketValidation(client, socket)
918
- socket[kParser].readMore()
919
- if (socket.destroyed) {
920
- return
921
- }
922
- return
923
- }
924
-
925
- if (socket[kIdleSocketValidation] === 1) {
926
- socket[kParser].readMore()
927
- if (socket.destroyed) {
928
- return
929
- }
930
- return
931
- }
932
- }
933
-
934
- if (client[kRunning] === 0) {
935
- socket[kParser].readMore()
936
- if (socket.destroyed) {
937
- return
938
- }
939
- }
940
-
941
- if (client[kSize] === 0) {
942
- if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
943
- socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
944
- }
945
- } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
946
- if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
947
- const request = client[kQueue][client[kRunningIdx]]
948
- const headersTimeout = request.headersTimeout != null
949
- ? request.headersTimeout
950
- : client[kHeadersTimeout]
951
- socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS)
952
- }
953
- }
954
- }
955
- }
956
-
957
- // https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
958
- function shouldSendContentLength (method) {
959
- return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
960
- }
961
-
962
- function writeH1 (client, request) {
963
- const { method, path, host, upgrade, blocking, reset } = request
964
-
965
- let { body, headers, contentLength } = request
966
-
967
- // https://tools.ietf.org/html/rfc7231#section-4.3.1
968
- // https://tools.ietf.org/html/rfc7231#section-4.3.2
969
- // https://tools.ietf.org/html/rfc7231#section-4.3.5
970
-
971
- // Sending a payload body on a request that does not
972
- // expect it can cause undefined behavior on some
973
- // servers and corrupt connection state. Do not
974
- // re-use the connection for further requests.
975
-
976
- const expectsPayload = (
977
- method === 'PUT' ||
978
- method === 'POST' ||
979
- method === 'PATCH' ||
980
- method === 'QUERY' ||
981
- method === 'PROPFIND' ||
982
- method === 'PROPPATCH'
983
- )
984
-
985
- if (util.isFormDataLike(body)) {
986
- if (!extractBody) {
987
- extractBody = require('../web/fetch/body.js').extractBody
988
- }
989
-
990
- const [bodyStream, contentType] = extractBody(body)
991
- if (request.contentType == null) {
992
- headers.push('content-type', contentType)
993
- }
994
- body = bodyStream.stream
995
- contentLength = bodyStream.length
996
- } else if (util.isBlobLike(body) && request.contentType == null && body.type) {
997
- headers.push('content-type', body.type)
998
- }
999
-
1000
- if (body && typeof body.read === 'function') {
1001
- // Try to read EOF in order to get length.
1002
- body.read(0)
1003
- }
1004
-
1005
- const bodyLength = util.bodyLength(body)
1006
-
1007
- contentLength = bodyLength ?? contentLength
1008
-
1009
- if (contentLength === null) {
1010
- contentLength = request.contentLength
1011
- }
1012
-
1013
- if (contentLength === 0 && !expectsPayload) {
1014
- // https://tools.ietf.org/html/rfc7230#section-3.3.2
1015
- // A user agent SHOULD NOT send a Content-Length header field when
1016
- // the request message does not contain a payload body and the method
1017
- // semantics do not anticipate such a body.
1018
-
1019
- contentLength = null
1020
- }
1021
-
1022
- // https://github.com/nodejs/undici/issues/2046
1023
- // A user agent may send a Content-Length header with 0 value, this should be allowed.
1024
- if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
1025
- if (client[kStrictContentLength]) {
1026
- util.errorRequest(client, request, new RequestContentLengthMismatchError())
1027
- return false
1028
- }
1029
-
1030
- process.emitWarning(new RequestContentLengthMismatchError())
1031
- }
1032
-
1033
- const socket = client[kSocket]
1034
- clearIdleSocketValidation(socket)
1035
-
1036
- const abort = (err) => {
1037
- if (request.aborted || request.completed) {
1038
- return
1039
- }
1040
-
1041
- util.errorRequest(client, request, err || new RequestAbortedError())
1042
-
1043
- util.destroy(body)
1044
- util.destroy(socket, new InformationalError('aborted'))
1045
- }
1046
-
1047
- try {
1048
- request.onConnect(abort)
1049
- } catch (err) {
1050
- util.errorRequest(client, request, err)
1051
- }
1052
-
1053
- if (request.aborted) {
1054
- return false
1055
- }
1056
-
1057
- if (method === 'HEAD') {
1058
- // https://github.com/mcollina/undici/issues/258
1059
- // Close after a HEAD request to interop with misbehaving servers
1060
- // that may send a body in the response.
1061
-
1062
- socket[kReset] = true
1063
- }
1064
-
1065
- if (upgrade || method === 'CONNECT') {
1066
- // On CONNECT or upgrade, block pipeline from dispatching further
1067
- // requests on this connection.
1068
-
1069
- socket[kReset] = true
1070
- }
1071
-
1072
- if (reset != null) {
1073
- socket[kReset] = reset
1074
- }
1075
-
1076
- if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
1077
- socket[kReset] = true
1078
- }
1079
-
1080
- if (blocking) {
1081
- socket[kBlocking] = true
1082
- }
1083
-
1084
- let header = `${method} ${path} HTTP/1.1\r\n`
1085
-
1086
- if (typeof host === 'string') {
1087
- header += `host: ${host}\r\n`
1088
- } else {
1089
- header += client[kHostHeader]
1090
- }
1091
-
1092
- if (upgrade) {
1093
- header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`
1094
- } else if (client[kPipelining] && !socket[kReset]) {
1095
- header += 'connection: keep-alive\r\n'
1096
- } else {
1097
- header += 'connection: close\r\n'
1098
- }
1099
-
1100
- if (Array.isArray(headers)) {
1101
- for (let n = 0; n < headers.length; n += 2) {
1102
- const key = headers[n + 0]
1103
- const val = headers[n + 1]
1104
-
1105
- if (Array.isArray(val)) {
1106
- for (let i = 0; i < val.length; i++) {
1107
- header += `${key}: ${val[i]}\r\n`
1108
- }
1109
- } else {
1110
- header += `${key}: ${val}\r\n`
1111
- }
1112
- }
1113
- }
1114
-
1115
- if (channels.sendHeaders.hasSubscribers) {
1116
- channels.sendHeaders.publish({ request, headers: header, socket })
1117
- }
1118
-
1119
- /* istanbul ignore else: assertion */
1120
- if (!body || bodyLength === 0) {
1121
- writeBuffer(abort, null, client, request, socket, contentLength, header, expectsPayload)
1122
- } else if (util.isBuffer(body)) {
1123
- writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload)
1124
- } else if (util.isBlobLike(body)) {
1125
- if (typeof body.stream === 'function') {
1126
- writeIterable(abort, body.stream(), client, request, socket, contentLength, header, expectsPayload)
1127
- } else {
1128
- writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload)
1129
- }
1130
- } else if (util.isStream(body)) {
1131
- writeStream(abort, body, client, request, socket, contentLength, header, expectsPayload)
1132
- } else if (util.isIterable(body)) {
1133
- writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload)
1134
- } else {
1135
- assert(false)
1136
- }
1137
-
1138
- return true
1139
- }
1140
-
1141
- function writeStream (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1142
- assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined')
1143
-
1144
- let finished = false
1145
-
1146
- const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
1147
-
1148
- const onData = function (chunk) {
1149
- if (finished) {
1150
- return
1151
- }
1152
-
1153
- try {
1154
- if (!writer.write(chunk) && this.pause) {
1155
- this.pause()
1156
- }
1157
- } catch (err) {
1158
- util.destroy(this, err)
1159
- }
1160
- }
1161
- const onDrain = function () {
1162
- if (finished) {
1163
- return
1164
- }
1165
-
1166
- if (body.resume) {
1167
- body.resume()
1168
- }
1169
- }
1170
- const onClose = function () {
1171
- // 'close' might be emitted *before* 'error' for
1172
- // broken streams. Wait a tick to avoid this case.
1173
- queueMicrotask(() => {
1174
- // It's only safe to remove 'error' listener after
1175
- // 'close'.
1176
- body.removeListener('error', onFinished)
1177
- })
1178
-
1179
- if (!finished) {
1180
- const err = new RequestAbortedError()
1181
- queueMicrotask(() => onFinished(err))
1182
- }
1183
- }
1184
- const onFinished = function (err) {
1185
- if (finished) {
1186
- return
1187
- }
1188
-
1189
- finished = true
1190
-
1191
- assert(socket.destroyed || (socket[kWriting] && client[kRunning] <= 1))
1192
-
1193
- socket
1194
- .off('drain', onDrain)
1195
- .off('error', onFinished)
1196
-
1197
- body
1198
- .removeListener('data', onData)
1199
- .removeListener('end', onFinished)
1200
- .removeListener('close', onClose)
1201
-
1202
- if (!err) {
1203
- try {
1204
- writer.end()
1205
- } catch (er) {
1206
- err = er
1207
- }
1208
- }
1209
-
1210
- writer.destroy(err)
1211
-
1212
- if (err && (err.code !== 'UND_ERR_INFO' || err.message !== 'reset')) {
1213
- util.destroy(body, err)
1214
- } else {
1215
- util.destroy(body)
1216
- }
1217
- }
1218
-
1219
- body
1220
- .on('data', onData)
1221
- .on('end', onFinished)
1222
- .on('error', onFinished)
1223
- .on('close', onClose)
1224
-
1225
- if (body.resume) {
1226
- body.resume()
1227
- }
1228
-
1229
- socket
1230
- .on('drain', onDrain)
1231
- .on('error', onFinished)
1232
-
1233
- if (body.errorEmitted ?? body.errored) {
1234
- setImmediate(() => onFinished(body.errored))
1235
- } else if (body.endEmitted ?? body.readableEnded) {
1236
- setImmediate(() => onFinished(null))
1237
- }
1238
-
1239
- if (body.closeEmitted ?? body.closed) {
1240
- setImmediate(onClose)
1241
- }
1242
- }
1243
-
1244
- function writeBuffer (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1245
- try {
1246
- if (!body) {
1247
- if (contentLength === 0) {
1248
- socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
1249
- } else {
1250
- assert(contentLength === null, 'no body must not have content length')
1251
- socket.write(`${header}\r\n`, 'latin1')
1252
- }
1253
- } else if (util.isBuffer(body)) {
1254
- assert(contentLength === body.byteLength, 'buffer body must have content length')
1255
-
1256
- socket.cork()
1257
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1258
- socket.write(body)
1259
- socket.uncork()
1260
- request.onBodySent(body)
1261
-
1262
- if (!expectsPayload && request.reset !== false) {
1263
- socket[kReset] = true
1264
- }
1265
- }
1266
- request.onRequestSent()
1267
-
1268
- client[kResume]()
1269
- } catch (err) {
1270
- abort(err)
1271
- }
1272
- }
1273
-
1274
- async function writeBlob (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1275
- assert(contentLength === body.size, 'blob body must have content length')
1276
-
1277
- try {
1278
- if (contentLength != null && contentLength !== body.size) {
1279
- throw new RequestContentLengthMismatchError()
1280
- }
1281
-
1282
- const buffer = Buffer.from(await body.arrayBuffer())
1283
-
1284
- socket.cork()
1285
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1286
- socket.write(buffer)
1287
- socket.uncork()
1288
-
1289
- request.onBodySent(buffer)
1290
- request.onRequestSent()
1291
-
1292
- if (!expectsPayload && request.reset !== false) {
1293
- socket[kReset] = true
1294
- }
1295
-
1296
- client[kResume]()
1297
- } catch (err) {
1298
- abort(err)
1299
- }
1300
- }
1301
-
1302
- async function writeIterable (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1303
- assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined')
1304
-
1305
- let callback = null
1306
- function onDrain () {
1307
- if (callback) {
1308
- const cb = callback
1309
- callback = null
1310
- cb()
1311
- }
1312
- }
1313
-
1314
- const waitForDrain = () => new Promise((resolve, reject) => {
1315
- assert(callback === null)
1316
-
1317
- if (socket[kError]) {
1318
- reject(socket[kError])
1319
- } else {
1320
- callback = resolve
1321
- }
1322
- })
1323
-
1324
- socket
1325
- .on('close', onDrain)
1326
- .on('drain', onDrain)
1327
-
1328
- const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
1329
- try {
1330
- // It's up to the user to somehow abort the async iterable.
1331
- for await (const chunk of body) {
1332
- if (socket[kError]) {
1333
- throw socket[kError]
1334
- }
1335
-
1336
- if (!writer.write(chunk)) {
1337
- await waitForDrain()
1338
- }
1339
- }
1340
-
1341
- writer.end()
1342
- } catch (err) {
1343
- writer.destroy(err)
1344
- } finally {
1345
- socket
1346
- .off('close', onDrain)
1347
- .off('drain', onDrain)
1348
- }
1349
- }
1350
-
1351
- class AsyncWriter {
1352
- constructor ({ abort, socket, request, contentLength, client, expectsPayload, header }) {
1353
- this.socket = socket
1354
- this.request = request
1355
- this.contentLength = contentLength
1356
- this.client = client
1357
- this.bytesWritten = 0
1358
- this.expectsPayload = expectsPayload
1359
- this.header = header
1360
- this.abort = abort
1361
-
1362
- socket[kWriting] = true
1363
- }
1364
-
1365
- write (chunk) {
1366
- const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this
1367
-
1368
- if (socket[kError]) {
1369
- throw socket[kError]
1370
- }
1371
-
1372
- if (socket.destroyed) {
1373
- return false
1374
- }
1375
-
1376
- const len = Buffer.byteLength(chunk)
1377
- if (!len) {
1378
- return true
1379
- }
1380
-
1381
- // We should defer writing chunks.
1382
- if (contentLength !== null && bytesWritten + len > contentLength) {
1383
- if (client[kStrictContentLength]) {
1384
- throw new RequestContentLengthMismatchError()
1385
- }
1386
-
1387
- process.emitWarning(new RequestContentLengthMismatchError())
1388
- }
1389
-
1390
- socket.cork()
1391
-
1392
- if (bytesWritten === 0) {
1393
- if (!expectsPayload && request.reset !== false) {
1394
- socket[kReset] = true
1395
- }
1396
-
1397
- if (contentLength === null) {
1398
- socket.write(`${header}transfer-encoding: chunked\r\n`, 'latin1')
1399
- } else {
1400
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1401
- }
1402
- }
1403
-
1404
- if (contentLength === null) {
1405
- socket.write(`\r\n${len.toString(16)}\r\n`, 'latin1')
1406
- }
1407
-
1408
- this.bytesWritten += len
1409
-
1410
- const ret = socket.write(chunk)
1411
-
1412
- socket.uncork()
1413
-
1414
- request.onBodySent(chunk)
1415
-
1416
- if (!ret) {
1417
- if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
1418
- // istanbul ignore else: only for jest
1419
- if (socket[kParser].timeout.refresh) {
1420
- socket[kParser].timeout.refresh()
1421
- }
1422
- }
1423
- }
1424
-
1425
- return ret
1426
- }
1427
-
1428
- end () {
1429
- const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this
1430
- request.onRequestSent()
1431
-
1432
- socket[kWriting] = false
1433
-
1434
- if (socket[kError]) {
1435
- throw socket[kError]
1436
- }
1437
-
1438
- if (socket.destroyed) {
1439
- return
1440
- }
1441
-
1442
- if (bytesWritten === 0) {
1443
- if (expectsPayload) {
1444
- // https://tools.ietf.org/html/rfc7230#section-3.3.2
1445
- // A user agent SHOULD send a Content-Length in a request message when
1446
- // no Transfer-Encoding is sent and the request method defines a meaning
1447
- // for an enclosed payload body.
1448
-
1449
- socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
1450
- } else {
1451
- socket.write(`${header}\r\n`, 'latin1')
1452
- }
1453
- } else if (contentLength === null) {
1454
- socket.write('\r\n0\r\n\r\n', 'latin1')
1455
- }
1456
-
1457
- if (contentLength !== null && bytesWritten !== contentLength) {
1458
- if (client[kStrictContentLength]) {
1459
- throw new RequestContentLengthMismatchError()
1460
- } else {
1461
- process.emitWarning(new RequestContentLengthMismatchError())
1462
- }
1463
- }
1464
-
1465
- if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
1466
- // istanbul ignore else: only for jest
1467
- if (socket[kParser].timeout.refresh) {
1468
- socket[kParser].timeout.refresh()
1469
- }
1470
- }
1471
-
1472
- client[kResume]()
1473
- }
1474
-
1475
- destroy (err) {
1476
- const { socket, client, abort } = this
1477
-
1478
- socket[kWriting] = false
1479
-
1480
- if (err) {
1481
- assert(client[kRunning] <= 1, 'pipeline should only contain this request')
1482
- abort(err)
1483
- }
1484
- }
1485
- }
1486
-
1487
- module.exports = connectH1