rubygems-update 3.0.3 → 3.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (806) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5633 -0
  3. data/CODE_OF_CONDUCT.md +62 -24
  4. data/CONTRIBUTING.md +111 -21
  5. data/MAINTAINERS.txt +1 -6
  6. data/Manifest.txt +216 -101
  7. data/POLICIES.md +70 -27
  8. data/README.md +40 -19
  9. data/UPGRADING.md +5 -81
  10. data/bin/gem +2 -16
  11. data/bin/update_rubygems +5 -5
  12. data/bundler/CHANGELOG.md +2698 -1256
  13. data/bundler/LICENSE.md +18 -19
  14. data/bundler/README.md +10 -14
  15. data/bundler/UPGRADING.md +222 -0
  16. data/bundler/bundler.gemspec +13 -33
  17. data/bundler/exe/bundle +26 -11
  18. data/bundler/exe/bundler +1 -1
  19. data/bundler/lib/bundler/.document +1 -0
  20. data/bundler/lib/bundler/build_metadata.rb +5 -13
  21. data/bundler/lib/bundler/capistrano.rb +4 -4
  22. data/bundler/lib/bundler/cli/add.rb +28 -16
  23. data/bundler/lib/bundler/cli/binstubs.rb +11 -3
  24. data/bundler/lib/bundler/cli/cache.rb +24 -17
  25. data/bundler/lib/bundler/cli/check.rb +5 -3
  26. data/bundler/lib/bundler/cli/clean.rb +1 -1
  27. data/bundler/lib/bundler/cli/common.rb +41 -13
  28. data/bundler/lib/bundler/cli/config.rb +170 -86
  29. data/bundler/lib/bundler/cli/console.rb +3 -3
  30. data/bundler/lib/bundler/cli/doctor.rb +27 -10
  31. data/bundler/lib/bundler/cli/exec.rb +8 -25
  32. data/bundler/lib/bundler/cli/fund.rb +36 -0
  33. data/bundler/lib/bundler/cli/gem.rb +261 -48
  34. data/bundler/lib/bundler/cli/info.rb +52 -8
  35. data/bundler/lib/bundler/cli/init.rb +7 -3
  36. data/bundler/lib/bundler/cli/inject.rb +1 -1
  37. data/bundler/lib/bundler/cli/install.rb +38 -66
  38. data/bundler/lib/bundler/cli/issue.rb +8 -7
  39. data/bundler/lib/bundler/cli/list.rb +19 -11
  40. data/bundler/lib/bundler/cli/lock.rb +11 -4
  41. data/bundler/lib/bundler/cli/open.rb +14 -9
  42. data/bundler/lib/bundler/cli/outdated.rb +152 -121
  43. data/bundler/lib/bundler/cli/platform.rb +2 -2
  44. data/bundler/lib/bundler/cli/plugin.rb +19 -2
  45. data/bundler/lib/bundler/cli/pristine.rb +6 -1
  46. data/bundler/lib/bundler/cli/remove.rb +1 -2
  47. data/bundler/lib/bundler/cli/show.rb +3 -3
  48. data/bundler/lib/bundler/cli/update.rb +49 -18
  49. data/bundler/lib/bundler/cli/viz.rb +1 -1
  50. data/bundler/lib/bundler/cli.rb +269 -165
  51. data/bundler/lib/bundler/compact_index_client/cache.rb +7 -24
  52. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  53. data/bundler/lib/bundler/compact_index_client/updater.rb +58 -57
  54. data/bundler/lib/bundler/compact_index_client.rb +28 -18
  55. data/bundler/lib/bundler/constants.rb +1 -1
  56. data/bundler/lib/bundler/current_ruby.rb +26 -11
  57. data/bundler/lib/bundler/definition.rb +371 -441
  58. data/bundler/lib/bundler/dependency.rb +29 -71
  59. data/bundler/lib/bundler/deployment.rb +1 -1
  60. data/bundler/lib/bundler/digest.rb +71 -0
  61. data/bundler/lib/bundler/dsl.rb +84 -116
  62. data/bundler/lib/bundler/endpoint_specification.rb +16 -14
  63. data/bundler/lib/bundler/env.rb +10 -15
  64. data/bundler/lib/bundler/environment_preserver.rb +32 -5
  65. data/bundler/lib/bundler/errors.rb +31 -14
  66. data/bundler/lib/bundler/feature_flag.rb +13 -33
  67. data/bundler/lib/bundler/fetcher/base.rb +7 -9
  68. data/bundler/lib/bundler/fetcher/compact_index.rb +46 -39
  69. data/bundler/lib/bundler/fetcher/dependency.rb +3 -7
  70. data/bundler/lib/bundler/fetcher/downloader.rb +15 -12
  71. data/bundler/lib/bundler/fetcher/index.rb +4 -30
  72. data/bundler/lib/bundler/fetcher.rb +40 -42
  73. data/bundler/lib/bundler/force_platform.rb +18 -0
  74. data/bundler/lib/bundler/friendly_errors.rb +49 -54
  75. data/bundler/lib/bundler/gem_helper.rb +79 -43
  76. data/bundler/lib/bundler/gem_helpers.rb +44 -28
  77. data/bundler/lib/bundler/gem_tasks.rb +1 -1
  78. data/bundler/lib/bundler/gem_version_promoter.rb +54 -99
  79. data/bundler/lib/bundler/graph.rb +5 -5
  80. data/bundler/lib/bundler/index.rb +16 -54
  81. data/bundler/lib/bundler/injector.rb +51 -17
  82. data/bundler/lib/bundler/inline.rb +28 -29
  83. data/bundler/lib/bundler/installer/gem_installer.rb +22 -23
  84. data/bundler/lib/bundler/installer/parallel_installer.rb +38 -51
  85. data/bundler/lib/bundler/installer/standalone.rb +62 -12
  86. data/bundler/lib/bundler/installer.rb +46 -97
  87. data/bundler/lib/bundler/lazy_specification.rb +88 -52
  88. data/bundler/lib/bundler/lockfile_generator.rb +4 -4
  89. data/bundler/lib/bundler/lockfile_parser.rb +40 -72
  90. data/bundler/{man → lib/bundler/man}/bundle-add.1 +29 -5
  91. data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +22 -4
  92. data/bundler/{man → lib/bundler/man}/bundle-binstubs.1 +6 -4
  93. data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +3 -5
  94. data/bundler/lib/bundler/man/bundle-cache.1 +61 -0
  95. data/bundler/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -15
  96. data/bundler/{man → lib/bundler/man}/bundle-check.1 +1 -1
  97. data/bundler/{man → lib/bundler/man}/bundle-clean.1 +2 -2
  98. data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  99. data/bundler/{man → lib/bundler/man}/bundle-config.1 +78 -60
  100. data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +96 -85
  101. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  102. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  103. data/bundler/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  104. data/bundler/{man → lib/bundler/man}/bundle-exec.1 +6 -6
  105. data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +6 -6
  106. data/bundler/lib/bundler/man/bundle-gem.1 +105 -0
  107. data/bundler/lib/bundler/man/bundle-gem.1.ronn +117 -0
  108. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  109. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/bundler/{man → lib/bundler/man}/bundle-info.1 +1 -1
  111. data/bundler/{man → lib/bundler/man}/bundle-init.1 +6 -2
  112. data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +3 -1
  113. data/bundler/{man → lib/bundler/man}/bundle-inject.1 +5 -2
  114. data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +3 -1
  115. data/bundler/{man → lib/bundler/man}/bundle-install.1 +42 -37
  116. data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +42 -38
  117. data/bundler/{man → lib/bundler/man}/bundle-list.1 +7 -7
  118. data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  119. data/bundler/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  120. data/bundler/{man → lib/bundler/man}/bundle-open.1 +22 -2
  121. data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +9 -1
  122. data/bundler/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  123. data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  124. data/bundler/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  125. data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  126. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  127. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  128. data/bundler/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  129. data/bundler/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  130. data/bundler/{man → lib/bundler/man}/bundle-show.1 +1 -1
  131. data/bundler/{man → lib/bundler/man}/bundle-update.1 +8 -8
  132. data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +8 -7
  133. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  134. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  135. data/bundler/{man → lib/bundler/man}/bundle-viz.1 +4 -1
  136. data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +2 -0
  137. data/bundler/{man → lib/bundler/man}/bundle.1 +17 -12
  138. data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  139. data/bundler/lib/bundler/man/gemfile.5 +723 -0
  140. data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +112 -95
  141. data/bundler/lib/bundler/man/index.txt +29 -0
  142. data/bundler/lib/bundler/match_metadata.rb +13 -0
  143. data/bundler/lib/bundler/match_platform.rb +1 -2
  144. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  145. data/bundler/lib/bundler/mirror.rb +10 -12
  146. data/bundler/lib/bundler/plugin/api/source.rb +29 -15
  147. data/bundler/lib/bundler/plugin/api.rb +1 -1
  148. data/bundler/lib/bundler/plugin/dsl.rb +1 -1
  149. data/bundler/lib/bundler/plugin/index.rb +31 -8
  150. data/bundler/lib/bundler/plugin/installer/git.rb +0 -4
  151. data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -9
  152. data/bundler/lib/bundler/plugin/installer.rb +40 -24
  153. data/bundler/lib/bundler/plugin/source_list.rb +5 -1
  154. data/bundler/lib/bundler/plugin.rb +103 -43
  155. data/bundler/lib/bundler/process_lock.rb +1 -1
  156. data/bundler/lib/bundler/remote_specification.rb +12 -9
  157. data/bundler/lib/bundler/resolver/base.rb +107 -0
  158. data/bundler/lib/bundler/resolver/candidate.rb +94 -0
  159. data/bundler/lib/bundler/resolver/incompatibility.rb +15 -0
  160. data/bundler/lib/bundler/resolver/package.rb +72 -0
  161. data/bundler/lib/bundler/resolver/root.rb +25 -0
  162. data/bundler/lib/bundler/resolver/spec_group.rb +49 -73
  163. data/bundler/lib/bundler/resolver.rb +341 -301
  164. data/bundler/lib/bundler/retry.rb +4 -4
  165. data/bundler/lib/bundler/ruby_dsl.rb +1 -1
  166. data/bundler/lib/bundler/ruby_version.rb +10 -38
  167. data/bundler/lib/bundler/rubygems_ext.rb +237 -92
  168. data/bundler/lib/bundler/rubygems_gem_installer.rb +87 -21
  169. data/bundler/lib/bundler/rubygems_integration.rb +179 -515
  170. data/bundler/lib/bundler/runtime.rb +25 -40
  171. data/bundler/lib/bundler/self_manager.rb +168 -0
  172. data/bundler/lib/bundler/settings.rb +163 -119
  173. data/bundler/lib/bundler/setup.rb +14 -12
  174. data/bundler/lib/bundler/shared_helpers.rb +62 -103
  175. data/bundler/lib/bundler/similarity_detector.rb +3 -3
  176. data/bundler/lib/bundler/source/git/git_proxy.rb +274 -128
  177. data/bundler/lib/bundler/source/git.rb +86 -62
  178. data/bundler/lib/bundler/source/metadata.rb +9 -9
  179. data/bundler/lib/bundler/source/path/installer.rb +11 -32
  180. data/bundler/lib/bundler/source/path.rb +29 -18
  181. data/bundler/lib/bundler/source/rubygems/remote.rb +3 -4
  182. data/bundler/lib/bundler/source/rubygems.rb +176 -206
  183. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  184. data/bundler/lib/bundler/source.rb +30 -10
  185. data/bundler/lib/bundler/source_list.rb +112 -67
  186. data/bundler/lib/bundler/source_map.rb +71 -0
  187. data/bundler/lib/bundler/spec_set.rb +96 -72
  188. data/bundler/lib/bundler/stub_specification.rb +45 -37
  189. data/bundler/lib/bundler/templates/Executable +3 -5
  190. data/bundler/lib/bundler/templates/Executable.bundler +22 -18
  191. data/bundler/lib/bundler/templates/Executable.standalone +4 -4
  192. data/bundler/lib/bundler/templates/Gemfile +0 -2
  193. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  194. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  195. data/bundler/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  196. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +22 -2
  197. data/bundler/lib/bundler/templates/newgem/README.md.tt +13 -15
  198. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +43 -5
  199. data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -4
  200. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  201. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  202. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  203. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  204. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  205. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  206. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  207. data/bundler/lib/bundler/templates/newgem/gitignore.tt +3 -0
  208. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  209. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  210. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  211. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +36 -41
  212. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  213. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  214. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  215. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  216. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  217. data/bundler/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  218. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  219. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  220. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  221. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -1
  222. data/bundler/lib/bundler/ui/shell.rb +39 -20
  223. data/bundler/lib/bundler/ui/silent.rb +21 -5
  224. data/bundler/lib/bundler/ui.rb +3 -3
  225. data/bundler/lib/bundler/uri_credentials_filter.rb +10 -4
  226. data/bundler/lib/bundler/uri_normalizer.rb +23 -0
  227. data/bundler/lib/bundler/vendor/.document +1 -0
  228. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  229. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  230. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  231. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  232. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +128 -0
  233. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  234. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1493 -425
  235. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  236. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  237. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  238. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  239. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
  240. data/bundler/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  241. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  242. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  243. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  244. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  245. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  246. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  247. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  248. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  249. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  250. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  251. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  252. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  253. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  254. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +243 -0
  255. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  256. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  257. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  258. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  259. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  260. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  261. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +25 -14
  262. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +20 -10
  263. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +34 -15
  264. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +63 -43
  265. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  266. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  267. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +83 -0
  268. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  269. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  270. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  271. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  272. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  273. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  274. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
  275. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  276. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +40 -6
  277. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  278. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  279. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  280. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +88 -13
  281. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
  282. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  283. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
  284. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  285. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  286. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +16 -9
  287. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  288. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  289. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  290. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +729 -0
  291. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  292. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  293. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1587 -0
  294. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  295. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  296. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  297. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  298. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  299. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  300. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +119 -0
  301. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  302. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  303. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  304. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  305. data/bundler/lib/bundler/vendored_fileutils.rb +1 -6
  306. data/bundler/lib/bundler/vendored_persistent.rb +2 -39
  307. data/bundler/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  308. data/bundler/lib/bundler/vendored_thor.rb +2 -2
  309. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  310. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  311. data/bundler/lib/bundler/version.rb +5 -20
  312. data/bundler/lib/bundler/vlad.rb +2 -2
  313. data/bundler/lib/bundler/worker.rb +26 -15
  314. data/bundler/lib/bundler/yaml_serializer.rb +3 -4
  315. data/bundler/lib/bundler.rb +290 -187
  316. data/hide_lib_for_update/note.txt +0 -4
  317. data/lib/rubygems/available_set.rb +7 -8
  318. data/lib/rubygems/basic_specification.rb +44 -31
  319. data/lib/rubygems/bundler_version_finder.rb +29 -51
  320. data/lib/rubygems/command.rb +114 -52
  321. data/lib/rubygems/command_manager.rb +38 -18
  322. data/lib/rubygems/commands/build_command.rb +77 -26
  323. data/lib/rubygems/commands/cert_command.rb +78 -76
  324. data/lib/rubygems/commands/check_command.rb +20 -22
  325. data/lib/rubygems/commands/cleanup_command.rb +36 -32
  326. data/lib/rubygems/commands/contents_command.rb +16 -18
  327. data/lib/rubygems/commands/dependency_command.rb +39 -50
  328. data/lib/rubygems/commands/environment_command.rb +11 -13
  329. data/lib/rubygems/commands/exec_command.rb +248 -0
  330. data/lib/rubygems/commands/fetch_command.rb +33 -16
  331. data/lib/rubygems/commands/generate_index_command.rb +18 -17
  332. data/lib/rubygems/commands/help_command.rb +10 -10
  333. data/lib/rubygems/commands/info_command.rb +11 -6
  334. data/lib/rubygems/commands/install_command.rb +45 -79
  335. data/lib/rubygems/commands/list_command.rb +9 -8
  336. data/lib/rubygems/commands/lock_command.rb +7 -9
  337. data/lib/rubygems/commands/mirror_command.rb +3 -4
  338. data/lib/rubygems/commands/open_command.rb +11 -14
  339. data/lib/rubygems/commands/outdated_command.rb +5 -6
  340. data/lib/rubygems/commands/owner_command.rb +33 -24
  341. data/lib/rubygems/commands/pristine_command.rb +70 -51
  342. data/lib/rubygems/commands/push_command.rb +26 -63
  343. data/lib/rubygems/commands/query_command.rb +21 -337
  344. data/lib/rubygems/commands/rdoc_command.rb +26 -26
  345. data/lib/rubygems/commands/search_command.rb +8 -8
  346. data/lib/rubygems/commands/server_command.rb +16 -77
  347. data/lib/rubygems/commands/setup_command.rb +282 -241
  348. data/lib/rubygems/commands/signin_command.rb +9 -10
  349. data/lib/rubygems/commands/signout_command.rb +7 -9
  350. data/lib/rubygems/commands/sources_command.rb +42 -26
  351. data/lib/rubygems/commands/specification_command.rb +25 -20
  352. data/lib/rubygems/commands/stale_command.rb +3 -3
  353. data/lib/rubygems/commands/uninstall_command.rb +61 -49
  354. data/lib/rubygems/commands/unpack_command.rb +15 -44
  355. data/lib/rubygems/commands/update_command.rb +133 -81
  356. data/lib/rubygems/commands/which_command.rb +8 -11
  357. data/lib/rubygems/commands/yank_command.rb +22 -19
  358. data/lib/rubygems/compatibility.rb +7 -5
  359. data/lib/rubygems/config_file.rb +101 -47
  360. data/lib/rubygems/core_ext/kernel_gem.rb +8 -12
  361. data/lib/rubygems/core_ext/kernel_require.rb +115 -84
  362. data/lib/rubygems/core_ext/kernel_warn.rb +35 -30
  363. data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
  364. data/lib/rubygems/defaults.rb +132 -56
  365. data/lib/rubygems/dependency.rb +44 -27
  366. data/lib/rubygems/dependency_installer.rb +49 -205
  367. data/lib/rubygems/dependency_list.rb +24 -25
  368. data/lib/rubygems/deprecate.rb +106 -12
  369. data/lib/rubygems/doctor.rb +22 -22
  370. data/lib/rubygems/errors.rb +8 -14
  371. data/lib/rubygems/exceptions.rb +45 -33
  372. data/lib/rubygems/ext/build_error.rb +2 -0
  373. data/lib/rubygems/ext/builder.rb +86 -93
  374. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +27 -0
  375. data/lib/rubygems/ext/cargo_builder.rb +360 -0
  376. data/lib/rubygems/ext/cmake_builder.rb +6 -7
  377. data/lib/rubygems/ext/configure_builder.rb +5 -8
  378. data/lib/rubygems/ext/ext_conf_builder.rb +44 -65
  379. data/lib/rubygems/ext/rake_builder.rb +7 -10
  380. data/lib/rubygems/ext.rb +7 -6
  381. data/lib/rubygems/gem_runner.rb +15 -26
  382. data/lib/rubygems/gemcutter_utilities.rb +221 -54
  383. data/lib/rubygems/indexer.rb +38 -53
  384. data/lib/rubygems/install_default_message.rb +2 -2
  385. data/lib/rubygems/install_message.rb +2 -2
  386. data/lib/rubygems/install_update_options.rb +73 -64
  387. data/lib/rubygems/installer.rb +231 -174
  388. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  389. data/lib/rubygems/local_remote_options.rb +22 -24
  390. data/lib/rubygems/mock_gem_ui.rb +2 -5
  391. data/lib/rubygems/name_tuple.rb +10 -14
  392. data/lib/rubygems/openssl.rb +7 -0
  393. data/lib/rubygems/optparse/.document +1 -0
  394. data/lib/rubygems/optparse/COPYING +56 -0
  395. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  396. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  397. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  398. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  399. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  400. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  401. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  402. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  403. data/lib/rubygems/optparse/lib/optparse.rb +2308 -0
  404. data/lib/rubygems/optparse.rb +3 -0
  405. data/lib/rubygems/package/digest_io.rb +0 -2
  406. data/lib/rubygems/package/file_source.rb +2 -4
  407. data/lib/rubygems/package/io_source.rb +4 -2
  408. data/lib/rubygems/package/old.rb +9 -11
  409. data/lib/rubygems/package/tar_header.rb +73 -66
  410. data/lib/rubygems/package/tar_reader/entry.rb +89 -11
  411. data/lib/rubygems/package/tar_reader.rb +1 -26
  412. data/lib/rubygems/package/tar_writer.rb +12 -22
  413. data/lib/rubygems/package.rb +142 -125
  414. data/lib/rubygems/package_task.rb +5 -11
  415. data/lib/rubygems/path_support.rb +3 -8
  416. data/lib/rubygems/platform.rb +113 -73
  417. data/lib/rubygems/psych_tree.rb +1 -1
  418. data/lib/rubygems/query_utils.rb +351 -0
  419. data/lib/rubygems/rdoc.rb +4 -16
  420. data/lib/rubygems/remote_fetcher.rb +64 -136
  421. data/lib/rubygems/request/connection_pools.rb +7 -11
  422. data/lib/rubygems/request/http_pool.rb +2 -3
  423. data/lib/rubygems/request.rb +31 -32
  424. data/lib/rubygems/request_set/gem_dependency_api.rb +134 -136
  425. data/lib/rubygems/request_set/lockfile/parser.rb +28 -28
  426. data/lib/rubygems/request_set/lockfile/tokenizer.rb +5 -5
  427. data/lib/rubygems/request_set/lockfile.rb +21 -20
  428. data/lib/rubygems/request_set.rb +32 -45
  429. data/lib/rubygems/requirement.rb +43 -65
  430. data/lib/rubygems/resolver/activation_request.rb +29 -53
  431. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  432. data/lib/rubygems/resolver/api_set.rb +33 -26
  433. data/lib/rubygems/resolver/api_specification.rb +30 -16
  434. data/lib/rubygems/resolver/best_set.rb +9 -11
  435. data/lib/rubygems/resolver/composed_set.rb +3 -5
  436. data/lib/rubygems/resolver/conflict.rb +12 -19
  437. data/lib/rubygems/resolver/current_set.rb +0 -2
  438. data/lib/rubygems/resolver/dependency_request.rb +3 -5
  439. data/lib/rubygems/resolver/git_set.rb +2 -4
  440. data/lib/rubygems/resolver/git_specification.rb +6 -8
  441. data/lib/rubygems/resolver/index_set.rb +4 -6
  442. data/lib/rubygems/resolver/index_specification.rb +38 -7
  443. data/lib/rubygems/resolver/installed_specification.rb +4 -6
  444. data/lib/rubygems/resolver/installer_set.rb +69 -27
  445. data/lib/rubygems/resolver/local_specification.rb +2 -4
  446. data/lib/rubygems/resolver/lock_set.rb +7 -9
  447. data/lib/rubygems/resolver/lock_specification.rb +6 -8
  448. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  449. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  450. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
  451. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  452. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
  453. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
  454. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
  455. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
  456. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
  457. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
  458. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
  459. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
  460. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +42 -9
  461. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +82 -8
  462. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  463. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  464. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  465. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
  466. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  467. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
  468. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  469. data/lib/rubygems/resolver/molinillo.rb +1 -1
  470. data/lib/rubygems/resolver/requirement_list.rb +0 -1
  471. data/lib/rubygems/resolver/set.rb +0 -3
  472. data/lib/rubygems/resolver/source_set.rb +0 -2
  473. data/lib/rubygems/resolver/spec_specification.rb +14 -2
  474. data/lib/rubygems/resolver/specification.rb +14 -3
  475. data/lib/rubygems/resolver/stats.rb +1 -1
  476. data/lib/rubygems/resolver/vendor_set.rb +1 -3
  477. data/lib/rubygems/resolver/vendor_specification.rb +3 -5
  478. data/lib/rubygems/resolver.rb +58 -54
  479. data/lib/rubygems/s3_uri_signer.rb +175 -0
  480. data/lib/rubygems/safe_yaml.rb +14 -16
  481. data/lib/rubygems/security/policies.rb +47 -47
  482. data/lib/rubygems/security/policy.rb +25 -29
  483. data/lib/rubygems/security/signer.rb +16 -18
  484. data/lib/rubygems/security/trust_dir.rb +5 -6
  485. data/lib/rubygems/security.rb +90 -69
  486. data/lib/rubygems/security_option.rb +7 -8
  487. data/lib/rubygems/source/git.rb +31 -31
  488. data/lib/rubygems/source/installed.rb +1 -3
  489. data/lib/rubygems/source/local.rb +4 -6
  490. data/lib/rubygems/source/lock.rb +0 -2
  491. data/lib/rubygems/source/specific_file.rb +1 -3
  492. data/lib/rubygems/source/vendor.rb +0 -2
  493. data/lib/rubygems/source.rb +50 -38
  494. data/lib/rubygems/source_list.rb +9 -13
  495. data/lib/rubygems/spec_fetcher.rb +52 -64
  496. data/lib/rubygems/specification.rb +444 -465
  497. data/lib/rubygems/specification_policy.rb +185 -87
  498. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  499. data/lib/rubygems/stub_specification.rb +28 -32
  500. data/lib/rubygems/text.rb +22 -22
  501. data/lib/rubygems/tsort/.document +1 -0
  502. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  503. data/lib/rubygems/tsort/lib/tsort.rb +452 -0
  504. data/lib/rubygems/tsort.rb +3 -0
  505. data/lib/rubygems/uninstaller.rb +110 -57
  506. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  507. data/lib/rubygems/update_suggestion.rb +69 -0
  508. data/lib/rubygems/uri.rb +126 -0
  509. data/lib/rubygems/uri_formatter.rb +2 -4
  510. data/lib/rubygems/user_interaction.rb +46 -49
  511. data/lib/rubygems/util/licenses.rb +511 -404
  512. data/lib/rubygems/util.rb +40 -56
  513. data/lib/rubygems/validator.rb +15 -37
  514. data/lib/rubygems/version.rb +50 -31
  515. data/lib/rubygems/version_option.rb +11 -5
  516. data/lib/rubygems/webauthn_listener/response.rb +161 -0
  517. data/lib/rubygems/webauthn_listener.rb +92 -0
  518. data/lib/rubygems.rb +307 -334
  519. data/rubygems-update.gemspec +6 -13
  520. data/setup.rb +11 -22
  521. data/test/rubygems/alternate_cert.pem +14 -14
  522. data/test/rubygems/alternate_cert_32.pem +15 -15
  523. data/test/rubygems/alternate_key.pem +25 -25
  524. data/test/rubygems/bundler_test_gem.rb +419 -0
  525. data/test/rubygems/ca_cert.pem +74 -65
  526. data/test/rubygems/child_cert.pem +15 -16
  527. data/test/rubygems/child_cert_32.pem +15 -16
  528. data/test/rubygems/child_key.pem +25 -25
  529. data/test/rubygems/client.pem +103 -45
  530. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  531. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  532. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  533. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  534. data/test/rubygems/encrypted_private_key.pem +26 -26
  535. data/test/rubygems/expired_cert.pem +15 -15
  536. data/test/rubygems/future_cert.pem +15 -15
  537. data/test/rubygems/future_cert_32.pem +15 -15
  538. data/test/rubygems/grandchild_cert.pem +15 -16
  539. data/test/rubygems/grandchild_cert_32.pem +15 -16
  540. data/test/rubygems/grandchild_key.pem +25 -25
  541. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +518 -507
  542. data/{lib → test}/rubygems/installer_test_case.rb +115 -53
  543. data/test/rubygems/invalid_issuer_cert.pem +16 -16
  544. data/test/rubygems/invalid_issuer_cert_32.pem +16 -16
  545. data/test/rubygems/invalid_key.pem +25 -25
  546. data/test/rubygems/invalid_signer_cert.pem +15 -15
  547. data/test/rubygems/invalid_signer_cert_32.pem +15 -15
  548. data/test/rubygems/invalidchild_cert.pem +15 -16
  549. data/test/rubygems/invalidchild_cert_32.pem +15 -16
  550. data/test/rubygems/invalidchild_key.pem +25 -25
  551. data/{lib → test}/rubygems/package/tar_test_case.rb +51 -18
  552. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  553. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  554. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  555. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  556. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  557. data/test/rubygems/private_ec_key.pem +9 -0
  558. data/test/rubygems/private_key.pem +25 -25
  559. data/test/rubygems/public_cert.pem +16 -16
  560. data/test/rubygems/public_cert_32.pem +15 -15
  561. data/test/rubygems/public_key.pem +7 -7
  562. data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
  563. data/test/rubygems/rubygems_plugin.rb +2 -4
  564. data/test/rubygems/simple_gem.rb +1 -1
  565. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  566. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +12 -0
  567. data/test/rubygems/ssl_cert.pem +78 -17
  568. data/test/rubygems/ssl_key.pem +25 -13
  569. data/test/rubygems/test_bundled_ca.rb +44 -47
  570. data/test/rubygems/test_config.rb +6 -8
  571. data/test/rubygems/test_deprecate.rb +91 -11
  572. data/test/rubygems/test_exit.rb +17 -0
  573. data/test/rubygems/test_gem.rb +701 -878
  574. data/test/rubygems/test_gem_available_set.rb +24 -25
  575. data/test/rubygems/test_gem_bundler_version_finder.rb +42 -42
  576. data/test/rubygems/test_gem_command.rb +186 -39
  577. data/test/rubygems/test_gem_command_manager.rb +166 -36
  578. data/test/rubygems/test_gem_commands_build_command.rb +436 -52
  579. data/test/rubygems/test_gem_commands_cert_command.rb +193 -124
  580. data/test/rubygems/test_gem_commands_check_command.rb +9 -11
  581. data/test/rubygems/test_gem_commands_cleanup_command.rb +87 -62
  582. data/test/rubygems/test_gem_commands_contents_command.rb +73 -42
  583. data/test/rubygems/test_gem_commands_dependency_command.rb +39 -41
  584. data/test/rubygems/test_gem_commands_environment_command.rb +60 -48
  585. data/test/rubygems/test_gem_commands_exec_command.rb +851 -0
  586. data/test/rubygems/test_gem_commands_fetch_command.rb +163 -32
  587. data/test/rubygems/test_gem_commands_generate_index_command.rb +39 -9
  588. data/test/rubygems/test_gem_commands_help_command.rb +34 -19
  589. data/test/rubygems/test_gem_commands_info_command.rb +34 -9
  590. data/test/rubygems/test_gem_commands_install_command.rb +601 -174
  591. data/test/rubygems/test_gem_commands_list_command.rb +5 -7
  592. data/test/rubygems/test_gem_commands_lock_command.rb +11 -13
  593. data/test/rubygems/test_gem_commands_mirror.rb +3 -4
  594. data/test/rubygems/test_gem_commands_open_command.rb +16 -19
  595. data/test/rubygems/test_gem_commands_outdated_command.rb +24 -7
  596. data/test/rubygems/test_gem_commands_owner_command.rb +250 -49
  597. data/test/rubygems/test_gem_commands_pristine_command.rb +270 -89
  598. data/test/rubygems/test_gem_commands_push_command.rb +251 -69
  599. data/test/rubygems/test_gem_commands_query_command.rb +114 -89
  600. data/test/rubygems/test_gem_commands_search_command.rb +2 -4
  601. data/test/rubygems/test_gem_commands_server_command.rb +6 -46
  602. data/test/rubygems/test_gem_commands_setup_command.rb +334 -157
  603. data/test/rubygems/test_gem_commands_signin_command.rb +187 -27
  604. data/test/rubygems/test_gem_commands_signout_command.rb +3 -10
  605. data/test/rubygems/test_gem_commands_sources_command.rb +266 -33
  606. data/test/rubygems/test_gem_commands_specification_command.rb +81 -55
  607. data/test/rubygems/test_gem_commands_stale_command.rb +4 -6
  608. data/test/rubygems/test_gem_commands_uninstall_command.rb +251 -99
  609. data/test/rubygems/test_gem_commands_unpack_command.rb +32 -34
  610. data/test/rubygems/test_gem_commands_update_command.rb +412 -102
  611. data/test/rubygems/test_gem_commands_which_command.rb +12 -14
  612. data/test/rubygems/test_gem_commands_yank_command.rb +191 -26
  613. data/test/rubygems/test_gem_config_file.rb +120 -96
  614. data/test/rubygems/test_gem_dependency.rb +94 -86
  615. data/test/rubygems/test_gem_dependency_installer.rb +305 -388
  616. data/test/rubygems/test_gem_dependency_list.rb +66 -61
  617. data/test/rubygems/test_gem_dependency_resolution_error.rb +5 -7
  618. data/test/rubygems/test_gem_doctor.rb +73 -47
  619. data/test/rubygems/test_gem_ext_builder.rb +116 -108
  620. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  621. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +8 -0
  622. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +233 -0
  623. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +10 -0
  624. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +27 -0
  625. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +1 -0
  626. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  627. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +247 -0
  628. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  629. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +8 -0
  630. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +51 -0
  631. data/test/rubygems/test_gem_ext_cargo_builder.rb +167 -0
  632. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  633. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +60 -0
  634. data/test/rubygems/test_gem_ext_cmake_builder.rb +32 -37
  635. data/test/rubygems/test_gem_ext_configure_builder.rb +23 -31
  636. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +75 -79
  637. data/test/rubygems/test_gem_ext_rake_builder.rb +49 -30
  638. data/test/rubygems/test_gem_gem_runner.rb +58 -8
  639. data/test/rubygems/test_gem_gemcutter_utilities.rb +159 -76
  640. data/test/rubygems/test_gem_impossible_dependencies_error.rb +4 -6
  641. data/test/rubygems/test_gem_indexer.rb +120 -105
  642. data/test/rubygems/test_gem_install_update_options.rb +57 -33
  643. data/test/rubygems/test_gem_installer.rb +1230 -644
  644. data/test/rubygems/test_gem_local_remote_options.rb +11 -13
  645. data/test/rubygems/test_gem_name_tuple.rb +4 -6
  646. data/test/rubygems/test_gem_package.rb +390 -285
  647. data/test/rubygems/test_gem_package_old.rb +57 -56
  648. data/test/rubygems/test_gem_package_tar_header.rb +108 -50
  649. data/test/rubygems/test_gem_package_tar_reader.rb +54 -9
  650. data/test/rubygems/test_gem_package_tar_reader_entry.rb +168 -24
  651. data/test/rubygems/test_gem_package_tar_writer.rb +107 -101
  652. data/test/rubygems/test_gem_package_task.rb +58 -25
  653. data/test/rubygems/test_gem_path_support.rb +29 -29
  654. data/test/rubygems/test_gem_platform.rb +388 -199
  655. data/test/rubygems/test_gem_rdoc.rb +20 -155
  656. data/test/rubygems/test_gem_remote_fetcher.rb +475 -304
  657. data/test/rubygems/test_gem_request.rb +128 -85
  658. data/test/rubygems/test_gem_request_connection_pools.rb +32 -32
  659. data/test/rubygems/test_gem_request_set.rb +186 -110
  660. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +283 -264
  661. data/test/rubygems/test_gem_request_set_lockfile.rb +93 -94
  662. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +69 -70
  663. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +136 -136
  664. data/test/rubygems/test_gem_requirement.rb +140 -55
  665. data/test/rubygems/test_gem_resolver.rb +224 -115
  666. data/test/rubygems/test_gem_resolver_activation_request.rb +9 -40
  667. data/test/rubygems/test_gem_resolver_api_set.rb +79 -78
  668. data/test/rubygems/test_gem_resolver_api_specification.rb +47 -49
  669. data/test/rubygems/test_gem_resolver_best_set.rb +43 -22
  670. data/test/rubygems/test_gem_resolver_composed_set.rb +1 -3
  671. data/test/rubygems/test_gem_resolver_conflict.rb +12 -18
  672. data/test/rubygems/test_gem_resolver_dependency_request.rb +15 -17
  673. data/test/rubygems/test_gem_resolver_git_set.rb +22 -24
  674. data/test/rubygems/test_gem_resolver_git_specification.rb +22 -22
  675. data/test/rubygems/test_gem_resolver_index_set.rb +14 -16
  676. data/test/rubygems/test_gem_resolver_index_specification.rb +21 -18
  677. data/test/rubygems/test_gem_resolver_installed_specification.rb +5 -8
  678. data/test/rubygems/test_gem_resolver_installer_set.rb +106 -44
  679. data/test/rubygems/test_gem_resolver_local_specification.rb +7 -9
  680. data/test/rubygems/test_gem_resolver_lock_set.rb +15 -17
  681. data/test/rubygems/test_gem_resolver_lock_specification.rb +17 -19
  682. data/test/rubygems/test_gem_resolver_requirement_list.rb +1 -3
  683. data/test/rubygems/test_gem_resolver_specification.rb +8 -10
  684. data/test/rubygems/test_gem_resolver_vendor_set.rb +9 -11
  685. data/test/rubygems/test_gem_resolver_vendor_specification.rb +10 -12
  686. data/test/rubygems/test_gem_security.rb +109 -79
  687. data/test/rubygems/test_gem_security_policy.rb +102 -107
  688. data/test/rubygems/test_gem_security_signer.rb +51 -52
  689. data/test/rubygems/test_gem_security_trust_dir.rb +14 -16
  690. data/test/rubygems/test_gem_silent_ui.rb +47 -42
  691. data/test/rubygems/test_gem_source.rb +66 -51
  692. data/test/rubygems/test_gem_source_fetch_problem.rb +17 -8
  693. data/test/rubygems/test_gem_source_git.rb +78 -77
  694. data/test/rubygems/test_gem_source_installed.rb +16 -18
  695. data/test/rubygems/test_gem_source_list.rb +5 -5
  696. data/test/rubygems/test_gem_source_local.rb +15 -16
  697. data/test/rubygems/test_gem_source_lock.rb +31 -33
  698. data/test/rubygems/test_gem_source_specific_file.rb +18 -19
  699. data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
  700. data/test/rubygems/test_gem_source_vendor.rb +13 -15
  701. data/test/rubygems/test_gem_spec_fetcher.rb +74 -67
  702. data/test/rubygems/test_gem_specification.rb +1070 -1073
  703. data/test/rubygems/test_gem_stream_ui.rb +25 -23
  704. data/test/rubygems/test_gem_stub_specification.rb +39 -56
  705. data/test/rubygems/test_gem_text.rb +8 -3
  706. data/test/rubygems/test_gem_uninstaller.rb +269 -100
  707. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +3 -5
  708. data/test/rubygems/test_gem_update_suggestion.rb +208 -0
  709. data/test/rubygems/test_gem_uri.rb +39 -0
  710. data/test/rubygems/test_gem_uri_formatter.rb +14 -16
  711. data/test/rubygems/test_gem_util.rb +46 -34
  712. data/test/rubygems/test_gem_validator.rb +12 -15
  713. data/test/rubygems/test_gem_version.rb +50 -35
  714. data/test/rubygems/test_gem_version_option.rb +16 -18
  715. data/test/rubygems/test_kernel.rb +61 -61
  716. data/test/rubygems/test_project_sanity.rb +49 -0
  717. data/test/rubygems/test_remote_fetch_error.rb +8 -9
  718. data/test/rubygems/test_require.rb +415 -121
  719. data/test/rubygems/test_rubygems.rb +74 -0
  720. data/test/rubygems/test_webauthn_listener.rb +120 -0
  721. data/test/rubygems/test_webauthn_listener_response.rb +93 -0
  722. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +115 -51
  723. data/test/rubygems/wrong_key_cert.pem +15 -15
  724. data/test/rubygems/wrong_key_cert_32.pem +15 -15
  725. data/test/test_changelog_generator.rb +17 -0
  726. metadata +225 -244
  727. data/.rubocop.yml +0 -66
  728. data/.travis.yml +0 -38
  729. data/History.txt +0 -3965
  730. data/Rakefile +0 -372
  731. data/appveyor.yml +0 -43
  732. data/bundler/CODE_OF_CONDUCT.md +0 -42
  733. data/bundler/CONTRIBUTING.md +0 -17
  734. data/bundler/exe/bundle_ruby +0 -60
  735. data/bundler/lib/bundler/cli/package.rb +0 -49
  736. data/bundler/lib/bundler/compatibility_guard.rb +0 -14
  737. data/bundler/lib/bundler/dep_proxy.rb +0 -48
  738. data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
  739. data/bundler/lib/bundler/gemdeps.rb +0 -29
  740. data/bundler/lib/bundler/psyched_yaml.rb +0 -37
  741. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  742. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  743. data/bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  744. data/bundler/lib/bundler/templates/gems.rb +0 -8
  745. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  746. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  747. data/bundler/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  748. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  749. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  750. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  751. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  752. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  753. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  754. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  755. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  756. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  757. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  758. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  759. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  760. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  761. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  762. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  763. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  764. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  765. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  766. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  767. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  768. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  769. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  770. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  771. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  772. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  773. data/bundler/lib/bundler/version_ranges.rb +0 -76
  774. data/bundler/man/bundle-gem.1 +0 -80
  775. data/bundler/man/bundle-gem.ronn +0 -78
  776. data/bundler/man/bundle-package.1 +0 -55
  777. data/lib/rubygems/psych_additions.rb +0 -10
  778. data/lib/rubygems/server.rb +0 -878
  779. data/lib/rubygems/source_local.rb +0 -7
  780. data/lib/rubygems/source_specific_file.rb +0 -6
  781. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  782. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  783. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  784. data/lib/rubygems/syck_hack.rb +0 -77
  785. data/lib/ubygems.rb +0 -14
  786. data/test/rubygems/bogussources.rb +0 -9
  787. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  788. data/test/rubygems/test_gem_server.rb +0 -607
  789. data/util/CL2notes +0 -55
  790. data/util/ci +0 -77
  791. data/util/create_certs.rb +0 -171
  792. data/util/create_encrypted_key.rb +0 -16
  793. data/util/generate_spdx_license_list.rb +0 -61
  794. data/util/patch_with_prs.rb +0 -77
  795. data/util/rubocop +0 -8
  796. data/util/update_bundled_ca_certificates.rb +0 -139
  797. data/util/update_changelog.rb +0 -67
  798. /data/bundler/lib/bundler/{ssl_certs → man}/.document +0 -0
  799. /data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  800. /data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  801. /data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  802. /data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  803. /data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  804. /data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  805. /data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  806. /data/{bundler/lib/bundler/ssl_certs/index.rubygems.org → lib/rubygems/ssl_certs/rubygems.org}/GlobalSignRootCA.pem +0 -0
@@ -1,17 +1,7 @@
1
1
  require 'net/http'
2
- begin
3
- require 'net/https'
4
- rescue LoadError
5
- # net/https or openssl
6
- end if RUBY_VERSION < '1.9' # but only for 1.8
7
- require 'bundler/vendor/net-http-persistent/lib/net/http/faster'
8
- require 'uri'
2
+ require_relative '../../../../uri/lib/uri'
9
3
  require 'cgi' # for escaping
10
-
11
- begin
12
- require 'net/http/pipeline'
13
- rescue LoadError
14
- end
4
+ require_relative '../../../../connection_pool/lib/connection_pool'
15
5
 
16
6
  autoload :OpenSSL, 'openssl'
17
7
 
@@ -22,23 +12,19 @@ autoload :OpenSSL, 'openssl'
22
12
  # servers you wish to talk to. For each host:port you communicate with a
23
13
  # single persistent connection is created.
24
14
  #
25
- # Multiple Bundler::Persistent::Net::HTTP::Persistent objects will share the same set of
26
- # connections.
15
+ # Connections will be shared across threads through a connection pool to
16
+ # increase reuse of connections.
27
17
  #
28
- # For each thread you start a new connection will be created. A
29
- # Bundler::Persistent::Net::HTTP::Persistent connection will not be shared across threads.
30
- #
31
- # You can shut down the HTTP connections when done by calling #shutdown. You
32
- # should name your Bundler::Persistent::Net::HTTP::Persistent object if you intend to call this
33
- # method.
18
+ # You can shut down any remaining HTTP connections when done by calling
19
+ # #shutdown.
34
20
  #
35
21
  # Example:
36
22
  #
37
23
  # require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
38
24
  #
39
- # uri = URI 'http://example.com/awesome/web/service'
25
+ # uri = Bundler::URI 'http://example.com/awesome/web/service'
40
26
  #
41
- # http = Bundler::Persistent::Net::HTTP::Persistent.new 'my_app_name'
27
+ # http = Bundler::Persistent::Net::HTTP::Persistent.new
42
28
  #
43
29
  # # perform a GET
44
30
  # response = http.request uri
@@ -53,36 +39,40 @@ autoload :OpenSSL, 'openssl'
53
39
  # post = Net::HTTP::Post.new post_uri.path
54
40
  # post.set_form_data 'some' => 'cool data'
55
41
  #
56
- # # perform the POST, the URI is always required
42
+ # # perform the POST, the Bundler::URI is always required
57
43
  # response http.request post_uri, post
58
44
  #
59
45
  # Note that for GET, HEAD and other requests that do not have a body you want
60
- # to use URI#request_uri not URI#path. The request_uri contains the query
46
+ # to use Bundler::URI#request_uri not Bundler::URI#path. The request_uri contains the query
61
47
  # params which are sent in the body for other requests.
62
48
  #
63
- # == SSL
49
+ # == TLS/SSL
64
50
  #
65
- # SSL connections are automatically created depending upon the scheme of the
66
- # URI. SSL connections are automatically verified against the default
51
+ # TLS connections are automatically created depending upon the scheme of the
52
+ # Bundler::URI. TLS connections are automatically verified against the default
67
53
  # certificate store for your computer. You can override this by changing
68
54
  # verify_mode or by specifying an alternate cert_store.
69
55
  #
70
- # Here are the SSL settings, see the individual methods for documentation:
56
+ # Here are the TLS settings, see the individual methods for documentation:
71
57
  #
72
58
  # #certificate :: This client's certificate
73
- # #ca_file :: The certificate-authority
59
+ # #ca_file :: The certificate-authorities
60
+ # #ca_path :: Directory with certificate-authorities
74
61
  # #cert_store :: An SSL certificate store
62
+ # #ciphers :: List of SSl ciphers allowed
75
63
  # #private_key :: The client's SSL private key
76
64
  # #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
77
65
  # connection
66
+ # #ssl_timeout :: Session lifetime
78
67
  # #ssl_version :: Which specific SSL version to use
79
68
  # #verify_callback :: For server certificate verification
69
+ # #verify_depth :: Depth of certificate verification
80
70
  # #verify_mode :: How connections should be verified
81
71
  #
82
72
  # == Proxies
83
73
  #
84
74
  # A proxy can be set through #proxy= or at initialization time by providing a
85
- # second argument to ::new. The proxy may be the URI of the proxy server or
75
+ # second argument to ::new. The proxy may be the Bundler::URI of the proxy server or
86
76
  # <code>:ENV</code> which will consult environment variables.
87
77
  #
88
78
  # See #proxy= and #proxy_from_env for details.
@@ -102,14 +92,15 @@ autoload :OpenSSL, 'openssl'
102
92
  #
103
93
  # === Segregation
104
94
  #
105
- # By providing an application name to ::new you can separate your connections
106
- # from the connections of other applications.
95
+ # Each Bundler::Persistent::Net::HTTP::Persistent instance has its own pool of connections. There
96
+ # is no sharing with other instances (as was true in earlier versions).
107
97
  #
108
98
  # === Idle Timeout
109
99
  #
110
- # If a connection hasn't been used for this number of seconds it will automatically be
111
- # reset upon the next use to avoid attempting to send to a closed connection.
112
- # The default value is 5 seconds. nil means no timeout. Set through #idle_timeout.
100
+ # If a connection hasn't been used for this number of seconds it will
101
+ # automatically be reset upon the next use to avoid attempting to send to a
102
+ # closed connection. The default value is 5 seconds. nil means no timeout.
103
+ # Set through #idle_timeout.
113
104
  #
114
105
  # Reducing this value may help avoid the "too many connection resets" error
115
106
  # when sending non-idempotent requests while increasing this value will cause
@@ -124,8 +115,9 @@ autoload :OpenSSL, 'openssl'
124
115
  #
125
116
  # The number of requests that should be made before opening a new connection.
126
117
  # Typically many keep-alive capable servers tune this to 100 or less, so the
127
- # 101st request will fail with ECONNRESET. If unset (default), this value has no
128
- # effect, if set, connections will be reset on the request after max_requests.
118
+ # 101st request will fail with ECONNRESET. If unset (default), this value has
119
+ # no effect, if set, connections will be reset on the request after
120
+ # max_requests.
129
121
  #
130
122
  # === Open Timeout
131
123
  #
@@ -137,45 +129,6 @@ autoload :OpenSSL, 'openssl'
137
129
  # Socket options may be set on newly-created connections. See #socket_options
138
130
  # for details.
139
131
  #
140
- # === Non-Idempotent Requests
141
- #
142
- # By default non-idempotent requests will not be retried per RFC 2616. By
143
- # setting retry_change_requests to true requests will automatically be retried
144
- # once.
145
- #
146
- # Only do this when you know that retrying a POST or other non-idempotent
147
- # request is safe for your application and will not create duplicate
148
- # resources.
149
- #
150
- # The recommended way to handle non-idempotent requests is the following:
151
- #
152
- # require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
153
- #
154
- # uri = URI 'http://example.com/awesome/web/service'
155
- # post_uri = uri + 'create'
156
- #
157
- # http = Bundler::Persistent::Net::HTTP::Persistent.new 'my_app_name'
158
- #
159
- # post = Net::HTTP::Post.new post_uri.path
160
- # # ... fill in POST request
161
- #
162
- # begin
163
- # response = http.request post_uri, post
164
- # rescue Bundler::Persistent::Net::HTTP::Persistent::Error
165
- #
166
- # # POST failed, make a new request to verify the server did not process
167
- # # the request
168
- # exists_uri = uri + '...'
169
- # response = http.get exists_uri
170
- #
171
- # # Retry if it failed
172
- # retry if response.code == '404'
173
- # end
174
- #
175
- # The method of determining if the resource was created or not is unique to
176
- # the particular service you are using. Of course, you will want to add
177
- # protection from infinite looping.
178
- #
179
132
  # === Connection Termination
180
133
  #
181
134
  # If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
@@ -201,24 +154,27 @@ class Bundler::Persistent::Net::HTTP::Persistent
201
154
  HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc:
202
155
 
203
156
  ##
204
- # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
157
+ # The default connection pool size is 1/4 the allowed open files
158
+ # (<code>ulimit -n</code>) or 256 if your OS does not support file handle
159
+ # limits (typically windows).
205
160
 
206
- VERSION = '2.9.4'
161
+ if Process.const_defined? :RLIMIT_NOFILE
162
+ open_file_limits = Process.getrlimit(Process::RLIMIT_NOFILE)
163
+
164
+ # Under JRuby on Windows Process responds to `getrlimit` but returns something that does not match docs
165
+ if open_file_limits.respond_to?(:first)
166
+ DEFAULT_POOL_SIZE = open_file_limits.first / 4
167
+ else
168
+ DEFAULT_POOL_SIZE = 256
169
+ end
170
+ else
171
+ DEFAULT_POOL_SIZE = 256
172
+ end
207
173
 
208
174
  ##
209
- # Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
210
- # the exception list for ruby 1.x.
175
+ # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
211
176
 
212
- RETRIED_EXCEPTIONS = [ # :nodoc:
213
- (Net::ReadTimeout if Net.const_defined? :ReadTimeout),
214
- IOError,
215
- EOFError,
216
- Errno::ECONNRESET,
217
- Errno::ECONNABORTED,
218
- Errno::EPIPE,
219
- (OpenSSL::SSL::SSLError if HAVE_OPENSSL),
220
- Timeout::Error,
221
- ].compact
177
+ VERSION = '4.0.1'
222
178
 
223
179
  ##
224
180
  # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
@@ -241,38 +197,38 @@ class Bundler::Persistent::Net::HTTP::Persistent
241
197
  # NOTE: This may not work on ruby > 1.9.
242
198
 
243
199
  def self.detect_idle_timeout uri, max = 10
244
- uri = URI uri unless URI::Generic === uri
200
+ uri = Bundler::URI uri unless Bundler::URI::Generic === uri
245
201
  uri += '/'
246
202
 
247
203
  req = Net::HTTP::Head.new uri.request_uri
248
204
 
249
205
  http = new 'net-http-persistent detect_idle_timeout'
250
206
 
251
- connection = http.connection_for uri
207
+ http.connection_for uri do |connection|
208
+ sleep_time = 0
252
209
 
253
- sleep_time = 0
210
+ http = connection.http
254
211
 
255
- loop do
256
- response = connection.request req
212
+ loop do
213
+ response = http.request req
257
214
 
258
- $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
215
+ $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
259
216
 
260
- unless Net::HTTPOK === response then
261
- raise Error, "bad response code #{response.code} detecting idle timeout"
262
- end
217
+ unless Net::HTTPOK === response then
218
+ raise Error, "bad response code #{response.code} detecting idle timeout"
219
+ end
263
220
 
264
- break if sleep_time >= max
221
+ break if sleep_time >= max
265
222
 
266
- sleep_time += 1
223
+ sleep_time += 1
267
224
 
268
- $stderr.puts "sleeping #{sleep_time}" if $DEBUG
269
- sleep sleep_time
225
+ $stderr.puts "sleeping #{sleep_time}" if $DEBUG
226
+ sleep sleep_time
227
+ end
270
228
  end
271
229
  rescue
272
230
  # ignore StandardErrors, we've probably found the idle timeout.
273
231
  ensure
274
- http.shutdown
275
-
276
232
  return sleep_time unless $!
277
233
  end
278
234
 
@@ -281,7 +237,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
281
237
 
282
238
  attr_reader :certificate
283
239
 
240
+ ##
284
241
  # For Net::HTTP parity
242
+
285
243
  alias cert certificate
286
244
 
287
245
  ##
@@ -290,12 +248,23 @@ class Bundler::Persistent::Net::HTTP::Persistent
290
248
 
291
249
  attr_reader :ca_file
292
250
 
251
+ ##
252
+ # A directory of SSL certificates to be used as certificate authorities.
253
+ # Setting this will set verify_mode to VERIFY_PEER.
254
+
255
+ attr_reader :ca_path
256
+
293
257
  ##
294
258
  # An SSL certificate store. Setting this will override the default
295
259
  # certificate store. See verify_mode for more information.
296
260
 
297
261
  attr_reader :cert_store
298
262
 
263
+ ##
264
+ # The ciphers allowed for SSL connections
265
+
266
+ attr_reader :ciphers
267
+
299
268
  ##
300
269
  # Sends debug_output to this IO via Net::HTTP#set_debug_output.
301
270
  #
@@ -309,11 +278,6 @@ class Bundler::Persistent::Net::HTTP::Persistent
309
278
 
310
279
  attr_reader :generation # :nodoc:
311
280
 
312
- ##
313
- # Where this instance's connections live in the thread local variables
314
-
315
- attr_reader :generation_key # :nodoc:
316
-
317
281
  ##
318
282
  # Headers that are added to every request using Net::HTTP#add_field
319
283
 
@@ -337,6 +301,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
337
301
 
338
302
  attr_accessor :max_requests
339
303
 
304
+ ##
305
+ # Number of retries to perform if a request fails.
306
+ #
307
+ # See also #max_retries=, Net::HTTP#max_retries=.
308
+
309
+ attr_reader :max_retries
310
+
340
311
  ##
341
312
  # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
342
313
  # HTTP/1.1 servers.
@@ -349,8 +320,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
349
320
  attr_accessor :keep_alive
350
321
 
351
322
  ##
352
- # A name for this connection. Allows you to keep your connections apart
353
- # from everybody else's.
323
+ # The name for this collection of persistent connections.
354
324
 
355
325
  attr_reader :name
356
326
 
@@ -369,7 +339,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
369
339
 
370
340
  attr_reader :private_key
371
341
 
342
+ ##
372
343
  # For Net::HTTP parity
344
+
373
345
  alias key private_key
374
346
 
375
347
  ##
@@ -382,15 +354,20 @@ class Bundler::Persistent::Net::HTTP::Persistent
382
354
 
383
355
  attr_reader :no_proxy
384
356
 
357
+ ##
358
+ # Test-only accessor for the connection pool
359
+
360
+ attr_reader :pool # :nodoc:
361
+
385
362
  ##
386
363
  # Seconds to wait until reading one block. See Net::HTTP#read_timeout
387
364
 
388
365
  attr_accessor :read_timeout
389
366
 
390
367
  ##
391
- # Where this instance's request counts live in the thread local variables
368
+ # Seconds to wait until writing one block. See Net::HTTP#write_timeout
392
369
 
393
- attr_reader :request_key # :nodoc:
370
+ attr_accessor :write_timeout
394
371
 
395
372
  ##
396
373
  # By default SSL sessions are reused to avoid extra SSL handshakes. Set
@@ -418,17 +395,33 @@ class Bundler::Persistent::Net::HTTP::Persistent
418
395
  attr_reader :ssl_generation # :nodoc:
419
396
 
420
397
  ##
421
- # Where this instance's SSL connections live in the thread local variables
398
+ # SSL session lifetime
422
399
 
423
- attr_reader :ssl_generation_key # :nodoc:
400
+ attr_reader :ssl_timeout
424
401
 
425
402
  ##
426
403
  # SSL version to use.
427
404
  #
428
405
  # By default, the version will be negotiated automatically between client
429
- # and server. Ruby 1.9 and newer only.
406
+ # and server. Ruby 1.9 and newer only. Deprecated since Ruby 2.5.
430
407
 
431
- attr_reader :ssl_version if RUBY_VERSION > '1.9'
408
+ attr_reader :ssl_version
409
+
410
+ ##
411
+ # Minimum SSL version to use, e.g. :TLS1_1
412
+ #
413
+ # By default, the version will be negotiated automatically between client
414
+ # and server. Ruby 2.5 and newer only.
415
+
416
+ attr_reader :min_version
417
+
418
+ ##
419
+ # Maximum SSL version to use, e.g. :TLS1_2
420
+ #
421
+ # By default, the version will be negotiated automatically between client
422
+ # and server. Ruby 2.5 and newer only.
423
+
424
+ attr_reader :max_version
432
425
 
433
426
  ##
434
427
  # Where this instance's last-use times live in the thread local variables
@@ -436,50 +429,48 @@ class Bundler::Persistent::Net::HTTP::Persistent
436
429
  attr_reader :timeout_key # :nodoc:
437
430
 
438
431
  ##
439
- # SSL verification callback. Used when ca_file is set.
432
+ # SSL verification callback. Used when ca_file or ca_path is set.
440
433
 
441
434
  attr_reader :verify_callback
442
435
 
436
+ ##
437
+ # Sets the depth of SSL certificate verification
438
+
439
+ attr_reader :verify_depth
440
+
443
441
  ##
444
442
  # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER which verifies
445
443
  # the server certificate.
446
444
  #
447
- # If no ca_file or cert_store is set the default system certificate store is
448
- # used.
445
+ # If no ca_file, ca_path or cert_store is set the default system certificate
446
+ # store is used.
449
447
  #
450
448
  # You can use +verify_mode+ to override any default values.
451
449
 
452
450
  attr_reader :verify_mode
453
451
 
454
- ##
455
- # Enable retries of non-idempotent requests that change data (e.g. POST
456
- # requests) when the server has disconnected.
457
- #
458
- # This will in the worst case lead to multiple requests with the same data,
459
- # but it may be useful for some applications. Take care when enabling
460
- # this option to ensure it is safe to POST or perform other non-idempotent
461
- # requests to the server.
462
-
463
- attr_accessor :retry_change_requests
464
-
465
452
  ##
466
453
  # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
467
454
  #
468
- # Set +name+ to keep your connections apart from everybody else's. Not
469
- # required currently, but highly recommended. Your library name should be
470
- # good enough. This parameter will be required in a future version.
455
+ # Set a +name+ for fun. Your library name should be good enough, but this
456
+ # otherwise has no purpose.
471
457
  #
472
- # +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
458
+ # +proxy+ may be set to a Bundler::URI::HTTP or :ENV to pick up proxy options from
473
459
  # the environment. See proxy_from_env for details.
474
460
  #
475
- # In order to use a URI for the proxy you may need to do some extra work
476
- # beyond URI parsing if the proxy requires a password:
461
+ # In order to use a Bundler::URI for the proxy you may need to do some extra work
462
+ # beyond Bundler::URI parsing if the proxy requires a password:
477
463
  #
478
- # proxy = URI 'http://proxy.example'
464
+ # proxy = Bundler::URI 'http://proxy.example'
479
465
  # proxy.user = 'AzureDiamond'
480
466
  # proxy.password = 'hunter2'
467
+ #
468
+ # Set +pool_size+ to limit the maximum number of connections allowed.
469
+ # Defaults to 1/4 the number of allowed file handles or 256 if your OS does
470
+ # not support a limit on allowed file handles. You can have no more than
471
+ # this many threads with active HTTP transactions.
481
472
 
482
- def initialize name = nil, proxy = nil
473
+ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
483
474
  @name = name
484
475
 
485
476
  @debug_output = nil
@@ -491,40 +482,41 @@ class Bundler::Persistent::Net::HTTP::Persistent
491
482
  @keep_alive = 30
492
483
  @open_timeout = nil
493
484
  @read_timeout = nil
485
+ @write_timeout = nil
494
486
  @idle_timeout = 5
495
487
  @max_requests = nil
488
+ @max_retries = 1
496
489
  @socket_options = []
490
+ @ssl_generation = 0 # incremented when SSL session variables change
497
491
 
498
492
  @socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
499
493
  Socket.const_defined? :TCP_NODELAY
500
494
 
501
- key = ['net_http_persistent', name].compact
502
- @generation_key = [key, 'generations' ].join('_').intern
503
- @ssl_generation_key = [key, 'ssl_generations'].join('_').intern
504
- @request_key = [key, 'requests' ].join('_').intern
505
- @timeout_key = [key, 'timeouts' ].join('_').intern
495
+ @pool = Bundler::Persistent::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
496
+ Bundler::Persistent::Net::HTTP::Persistent::Connection.new Net::HTTP, http_args, @ssl_generation
497
+ end
506
498
 
507
499
  @certificate = nil
508
500
  @ca_file = nil
501
+ @ca_path = nil
502
+ @ciphers = nil
509
503
  @private_key = nil
504
+ @ssl_timeout = nil
510
505
  @ssl_version = nil
506
+ @min_version = nil
507
+ @max_version = nil
511
508
  @verify_callback = nil
509
+ @verify_depth = nil
512
510
  @verify_mode = nil
513
511
  @cert_store = nil
514
512
 
515
- @generation = 0 # incremented when proxy URI changes
516
- @ssl_generation = 0 # incremented when SSL session variables change
513
+ @generation = 0 # incremented when proxy Bundler::URI changes
517
514
 
518
515
  if HAVE_OPENSSL then
519
516
  @verify_mode = OpenSSL::SSL::VERIFY_PEER
520
517
  @reuse_ssl_sessions = OpenSSL::SSL.const_defined? :Session
521
518
  end
522
519
 
523
- @retry_change_requests = false
524
-
525
- @ruby_1 = RUBY_VERSION < '2'
526
- @retried_on_ruby_2 = !@ruby_1
527
-
528
520
  self.proxy = proxy if proxy
529
521
  end
530
522
 
@@ -549,6 +541,15 @@ class Bundler::Persistent::Net::HTTP::Persistent
549
541
  reconnect_ssl
550
542
  end
551
543
 
544
+ ##
545
+ # Sets the SSL certificate authority path.
546
+
547
+ def ca_path= path
548
+ @ca_path = path
549
+
550
+ reconnect_ssl
551
+ end
552
+
552
553
  ##
553
554
  # Overrides the default SSL certificate store used for verifying
554
555
  # connections.
@@ -560,117 +561,74 @@ class Bundler::Persistent::Net::HTTP::Persistent
560
561
  end
561
562
 
562
563
  ##
563
- # Finishes all connections on the given +thread+ that were created before
564
- # the given +generation+ in the threads +generation_key+ list.
565
- #
566
- # See #shutdown for a bunch of scary warning about misusing this method.
564
+ # The ciphers allowed for SSL connections
567
565
 
568
- def cleanup(generation, thread = Thread.current,
569
- generation_key = @generation_key) # :nodoc:
570
- timeouts = thread[@timeout_key]
566
+ def ciphers= ciphers
567
+ @ciphers = ciphers
571
568
 
572
- (0...generation).each do |old_generation|
573
- next unless thread[generation_key]
574
-
575
- conns = thread[generation_key].delete old_generation
576
-
577
- conns.each_value do |conn|
578
- finish conn, thread
579
-
580
- timeouts.delete conn.object_id if timeouts
581
- end if conns
582
- end
569
+ reconnect_ssl
583
570
  end
584
571
 
585
572
  ##
586
573
  # Creates a new connection for +uri+
587
574
 
588
575
  def connection_for uri
589
- Thread.current[@generation_key] ||= Hash.new { |h,k| h[k] = {} }
590
- Thread.current[@ssl_generation_key] ||= Hash.new { |h,k| h[k] = {} }
591
- Thread.current[@request_key] ||= Hash.new 0
592
- Thread.current[@timeout_key] ||= Hash.new EPOCH
593
-
594
576
  use_ssl = uri.scheme.downcase == 'https'
595
577
 
596
- if use_ssl then
597
- raise Bundler::Persistent::Net::HTTP::Persistent::Error, 'OpenSSL is not available' unless
598
- HAVE_OPENSSL
599
-
600
- ssl_generation = @ssl_generation
601
-
602
- ssl_cleanup ssl_generation
603
-
604
- connections = Thread.current[@ssl_generation_key][ssl_generation]
605
- else
606
- generation = @generation
607
-
608
- cleanup generation
609
-
610
- connections = Thread.current[@generation_key][generation]
611
- end
612
-
613
- net_http_args = [uri.host, uri.port]
614
- connection_id = net_http_args.join ':'
578
+ net_http_args = [uri.hostname, uri.port]
615
579
 
580
+ # I'm unsure if uri.host or uri.hostname should be checked against
581
+ # the proxy bypass list.
616
582
  if @proxy_uri and not proxy_bypass? uri.host, uri.port then
617
- connection_id << @proxy_connection_id
618
583
  net_http_args.concat @proxy_args
619
584
  else
620
585
  net_http_args.concat [nil, nil, nil, nil]
621
586
  end
622
587
 
623
- connection = connections[connection_id]
588
+ connection = @pool.checkout net_http_args
624
589
 
625
- unless connection = connections[connection_id] then
626
- connections[connection_id] = http_class.new(*net_http_args)
627
- connection = connections[connection_id]
628
- ssl connection if use_ssl
629
- else
630
- reset connection if expired? connection
631
- end
590
+ http = connection.http
632
591
 
633
- start connection unless connection.started?
592
+ connection.ressl @ssl_generation if
593
+ connection.ssl_generation != @ssl_generation
594
+
595
+ if not http.started? then
596
+ ssl http if use_ssl
597
+ start http
598
+ elsif expired? connection then
599
+ reset connection
600
+ end
634
601
 
635
- connection.read_timeout = @read_timeout if @read_timeout
636
- connection.keep_alive_timeout = @idle_timeout if @idle_timeout && connection.respond_to?(:keep_alive_timeout=)
602
+ http.keep_alive_timeout = @idle_timeout if @idle_timeout
603
+ http.max_retries = @max_retries if http.respond_to?(:max_retries=)
604
+ http.read_timeout = @read_timeout if @read_timeout
605
+ http.write_timeout = @write_timeout if
606
+ @write_timeout && http.respond_to?(:write_timeout=)
637
607
 
638
- connection
608
+ return yield connection
639
609
  rescue Errno::ECONNREFUSED
640
- address = connection.proxy_address || connection.address
641
- port = connection.proxy_port || connection.port
610
+ address = http.proxy_address || http.address
611
+ port = http.proxy_port || http.port
642
612
 
643
613
  raise Error, "connection refused: #{address}:#{port}"
644
614
  rescue Errno::EHOSTDOWN
645
- address = connection.proxy_address || connection.address
646
- port = connection.proxy_port || connection.port
615
+ address = http.proxy_address || http.address
616
+ port = http.proxy_port || http.port
647
617
 
648
618
  raise Error, "host down: #{address}:#{port}"
619
+ ensure
620
+ @pool.checkin net_http_args
649
621
  end
650
622
 
651
623
  ##
652
- # Returns an error message containing the number of requests performed on
653
- # this connection
654
-
655
- def error_message connection
656
- requests = Thread.current[@request_key][connection.object_id] - 1 # fixup
657
- last_use = Thread.current[@timeout_key][connection.object_id]
658
-
659
- age = Time.now - last_use
660
-
661
- "after #{requests} requests on #{connection.object_id}, " \
662
- "last used #{age} seconds ago"
663
- end
664
-
665
- ##
666
- # URI::escape wrapper
624
+ # CGI::escape wrapper
667
625
 
668
626
  def escape str
669
627
  CGI.escape str if str
670
628
  end
671
629
 
672
630
  ##
673
- # URI::unescape wrapper
631
+ # CGI::unescape wrapper
674
632
 
675
633
  def unescape str
676
634
  CGI.unescape str if str
@@ -682,26 +640,23 @@ class Bundler::Persistent::Net::HTTP::Persistent
682
640
  # maximum request count, false otherwise.
683
641
 
684
642
  def expired? connection
685
- requests = Thread.current[@request_key][connection.object_id]
686
- return true if @max_requests && requests >= @max_requests
643
+ return true if @max_requests && connection.requests >= @max_requests
687
644
  return false unless @idle_timeout
688
645
  return true if @idle_timeout.zero?
689
646
 
690
- last_used = Thread.current[@timeout_key][connection.object_id]
691
-
692
- Time.now - last_used > @idle_timeout
647
+ Time.now - connection.last_use > @idle_timeout
693
648
  end
694
649
 
695
650
  ##
696
651
  # Starts the Net::HTTP +connection+
697
652
 
698
- def start connection
699
- connection.set_debug_output @debug_output if @debug_output
700
- connection.open_timeout = @open_timeout if @open_timeout
653
+ def start http
654
+ http.set_debug_output @debug_output if @debug_output
655
+ http.open_timeout = @open_timeout if @open_timeout
701
656
 
702
- connection.start
657
+ http.start
703
658
 
704
- socket = connection.instance_variable_get :@socket
659
+ socket = http.instance_variable_get :@socket
705
660
 
706
661
  if socket then # for fakeweb
707
662
  @socket_options.each do |option|
@@ -713,96 +668,19 @@ class Bundler::Persistent::Net::HTTP::Persistent
713
668
  ##
714
669
  # Finishes the Net::HTTP +connection+
715
670
 
716
- def finish connection, thread = Thread.current
717
- if requests = thread[@request_key] then
718
- requests.delete connection.object_id
719
- end
720
-
671
+ def finish connection
721
672
  connection.finish
722
- rescue IOError
723
- end
724
673
 
725
- def http_class # :nodoc:
726
- if RUBY_VERSION > '2.0' then
727
- Net::HTTP
728
- elsif [:Artifice, :FakeWeb, :WebMock].any? { |klass|
729
- Object.const_defined?(klass)
730
- } or not @reuse_ssl_sessions then
731
- Net::HTTP
732
- else
733
- Bundler::Persistent::Net::HTTP::Persistent::SSLReuse
734
- end
674
+ connection.http.instance_variable_set :@last_communicated, nil
675
+ connection.http.instance_variable_set :@ssl_session, nil unless
676
+ @reuse_ssl_sessions
735
677
  end
736
678
 
737
679
  ##
738
680
  # Returns the HTTP protocol version for +uri+
739
681
 
740
682
  def http_version uri
741
- @http_versions["#{uri.host}:#{uri.port}"]
742
- end
743
-
744
- ##
745
- # Is +req+ idempotent according to RFC 2616?
746
-
747
- def idempotent? req
748
- case req
749
- when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
750
- Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
751
- true
752
- end
753
- end
754
-
755
- ##
756
- # Is the request +req+ idempotent or is retry_change_requests allowed.
757
- #
758
- # If +retried_on_ruby_2+ is true, true will be returned if we are on ruby,
759
- # retry_change_requests is allowed and the request is not idempotent.
760
-
761
- def can_retry? req, retried_on_ruby_2 = false
762
- return @retry_change_requests && !idempotent?(req) if retried_on_ruby_2
763
-
764
- @retry_change_requests || idempotent?(req)
765
- end
766
-
767
- if RUBY_VERSION > '1.9' then
768
- ##
769
- # Workaround for missing Net::HTTPHeader#connection_close? on Ruby 1.8
770
-
771
- def connection_close? header
772
- header.connection_close?
773
- end
774
-
775
- ##
776
- # Workaround for missing Net::HTTPHeader#connection_keep_alive? on Ruby 1.8
777
-
778
- def connection_keep_alive? header
779
- header.connection_keep_alive?
780
- end
781
- else
782
- ##
783
- # Workaround for missing Net::HTTPRequest#connection_close? on Ruby 1.8
784
-
785
- def connection_close? header
786
- header['connection'] =~ /close/ or header['proxy-connection'] =~ /close/
787
- end
788
-
789
- ##
790
- # Workaround for missing Net::HTTPRequest#connection_keep_alive? on Ruby
791
- # 1.8
792
-
793
- def connection_keep_alive? header
794
- header['connection'] =~ /keep-alive/ or
795
- header['proxy-connection'] =~ /keep-alive/
796
- end
797
- end
798
-
799
- ##
800
- # Deprecated in favor of #expired?
801
-
802
- def max_age # :nodoc:
803
- return Time.now + 1 unless @idle_timeout
804
-
805
- Time.now - @idle_timeout
683
+ @http_versions["#{uri.hostname}:#{uri.port}"]
806
684
  end
807
685
 
808
686
  ##
@@ -813,20 +691,20 @@ class Bundler::Persistent::Net::HTTP::Persistent
813
691
  end
814
692
 
815
693
  ##
816
- # Pipelines +requests+ to the HTTP server at +uri+ yielding responses if a
817
- # block is given. Returns all responses received.
694
+ # Set the maximum number of retries for a request.
818
695
  #
819
- # See
820
- # Net::HTTP::Pipeline[http://docs.seattlerb.org/net-http-pipeline/Net/HTTP/Pipeline.html]
821
- # for further details.
696
+ # Defaults to one retry.
822
697
  #
823
- # Only if <tt>net-http-pipeline</tt> was required before
824
- # <tt>net-http-persistent</tt> #pipeline will be present.
698
+ # Set this to 0 to disable retries.
699
+
700
+ def max_retries= retries
701
+ retries = retries.to_int
702
+
703
+ raise ArgumentError, "max_retries must be positive" if retries < 0
825
704
 
826
- def pipeline uri, requests, &block # :yields: responses
827
- connection = connection_for uri
705
+ @max_retries = retries
828
706
 
829
- connection.pipeline requests, &block
707
+ reconnect
830
708
  end
831
709
 
832
710
  ##
@@ -842,12 +720,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
842
720
  alias key= private_key=
843
721
 
844
722
  ##
845
- # Sets the proxy server. The +proxy+ may be the URI of the proxy server,
723
+ # Sets the proxy server. The +proxy+ may be the Bundler::URI of the proxy server,
846
724
  # the symbol +:ENV+ which will read the proxy from the environment or nil to
847
725
  # disable use of a proxy. See #proxy_from_env for details on setting the
848
726
  # proxy from the environment.
849
727
  #
850
- # If the proxy URI is set after requests have been made, the next request
728
+ # If the proxy Bundler::URI is set after requests have been made, the next request
851
729
  # will shut-down and re-open all connections.
852
730
  #
853
731
  # The +no_proxy+ query parameter can be used to specify hosts which shouldn't
@@ -858,16 +736,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
858
736
  def proxy= proxy
859
737
  @proxy_uri = case proxy
860
738
  when :ENV then proxy_from_env
861
- when URI::HTTP then proxy
739
+ when Bundler::URI::HTTP then proxy
862
740
  when nil then # ignore
863
- else raise ArgumentError, 'proxy must be :ENV or a URI::HTTP'
741
+ else raise ArgumentError, 'proxy must be :ENV or a Bundler::URI::HTTP'
864
742
  end
865
743
 
866
744
  @no_proxy.clear
867
745
 
868
746
  if @proxy_uri then
869
747
  @proxy_args = [
870
- @proxy_uri.host,
748
+ @proxy_uri.hostname,
871
749
  @proxy_uri.port,
872
750
  unescape(@proxy_uri.user),
873
751
  unescape(@proxy_uri.password),
@@ -885,13 +763,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
885
763
  end
886
764
 
887
765
  ##
888
- # Creates a URI for an HTTP proxy server from ENV variables.
766
+ # Creates a Bundler::URI for an HTTP proxy server from ENV variables.
889
767
  #
890
768
  # If +HTTP_PROXY+ is set a proxy will be returned.
891
769
  #
892
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the URI is given the
770
+ # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Bundler::URI is given the
893
771
  # indicated user and password unless HTTP_PROXY contains either of these in
894
- # the URI.
772
+ # the Bundler::URI.
895
773
  #
896
774
  # The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
897
775
  # be reached via proxy; if set it should be a comma separated list of
@@ -907,7 +785,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
907
785
 
908
786
  return nil if env_proxy.nil? or env_proxy.empty?
909
787
 
910
- uri = URI normalize_uri env_proxy
788
+ uri = Bundler::URI normalize_uri env_proxy
911
789
 
912
790
  env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
913
791
 
@@ -942,14 +820,15 @@ class Bundler::Persistent::Net::HTTP::Persistent
942
820
  end
943
821
 
944
822
  ##
945
- # Forces reconnection of HTTP connections.
823
+ # Forces reconnection of all HTTP connections, including TLS/SSL
824
+ # connections.
946
825
 
947
826
  def reconnect
948
827
  @generation += 1
949
828
  end
950
829
 
951
830
  ##
952
- # Forces reconnection of SSL connections.
831
+ # Forces reconnection of only TLS/SSL connections.
953
832
 
954
833
  def reconnect_ssl
955
834
  @ssl_generation += 1
@@ -959,18 +838,17 @@ class Bundler::Persistent::Net::HTTP::Persistent
959
838
  # Finishes then restarts the Net::HTTP +connection+
960
839
 
961
840
  def reset connection
962
- Thread.current[@request_key].delete connection.object_id
963
- Thread.current[@timeout_key].delete connection.object_id
841
+ http = connection.http
964
842
 
965
843
  finish connection
966
844
 
967
- start connection
845
+ start http
968
846
  rescue Errno::ECONNREFUSED
969
- e = Error.new "connection refused: #{connection.address}:#{connection.port}"
847
+ e = Error.new "connection refused: #{http.address}:#{http.port}"
970
848
  e.set_backtrace $@
971
849
  raise e
972
850
  rescue Errno::EHOSTDOWN
973
- e = Error.new "host down: #{connection.address}:#{connection.port}"
851
+ e = Error.new "host down: #{http.address}:#{http.port}"
974
852
  e.set_backtrace $@
975
853
  raise e
976
854
  end
@@ -982,92 +860,49 @@ class Bundler::Persistent::Net::HTTP::Persistent
982
860
  # If a block is passed #request behaves like Net::HTTP#request (the body of
983
861
  # the response will not have been read).
984
862
  #
985
- # +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list).
986
- #
987
- # If there is an error and the request is idempotent according to RFC 2616
988
- # it will be retried automatically.
863
+ # +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
989
864
 
990
865
  def request uri, req = nil, &block
991
- retried = false
992
- bad_response = false
993
-
994
- req = request_setup req || uri
995
-
996
- connection = connection_for uri
997
- connection_id = connection.object_id
998
-
999
- begin
1000
- Thread.current[@request_key][connection_id] += 1
1001
- response = connection.request req, &block
1002
-
1003
- if connection_close?(req) or
1004
- (response.http_version <= '1.0' and
1005
- not connection_keep_alive?(response)) or
1006
- connection_close?(response) then
1007
- connection.finish
866
+ uri = Bundler::URI uri
867
+ req = request_setup req || uri
868
+ response = nil
869
+
870
+ connection_for uri do |connection|
871
+ http = connection.http
872
+
873
+ begin
874
+ connection.requests += 1
875
+
876
+ response = http.request req, &block
877
+
878
+ if req.connection_close? or
879
+ (response.http_version <= '1.0' and
880
+ not response.connection_keep_alive?) or
881
+ response.connection_close? then
882
+ finish connection
883
+ end
884
+ rescue Exception # make sure to close the connection when it was interrupted
885
+ finish connection
886
+
887
+ raise
888
+ ensure
889
+ connection.last_use = Time.now
1008
890
  end
1009
- rescue Net::HTTPBadResponse => e
1010
- message = error_message connection
1011
-
1012
- finish connection
1013
-
1014
- raise Error, "too many bad responses #{message}" if
1015
- bad_response or not can_retry? req
1016
-
1017
- bad_response = true
1018
- retry
1019
- rescue *RETRIED_EXCEPTIONS => e # retried on ruby 2
1020
- request_failed e, req, connection if
1021
- retried or not can_retry? req, @retried_on_ruby_2
1022
-
1023
- reset connection
1024
-
1025
- retried = true
1026
- retry
1027
- rescue Errno::EINVAL, Errno::ETIMEDOUT => e # not retried on ruby 2
1028
- request_failed e, req, connection if retried or not can_retry? req
1029
-
1030
- reset connection
1031
-
1032
- retried = true
1033
- retry
1034
- rescue Exception => e
1035
- finish connection
1036
-
1037
- raise
1038
- ensure
1039
- Thread.current[@timeout_key][connection_id] = Time.now
1040
891
  end
1041
892
 
1042
- @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
893
+ @http_versions["#{uri.hostname}:#{uri.port}"] ||= response.http_version
1043
894
 
1044
895
  response
1045
896
  end
1046
897
 
1047
898
  ##
1048
- # Raises an Error for +exception+ which resulted from attempting the request
1049
- # +req+ on the +connection+.
1050
- #
1051
- # Finishes the +connection+.
1052
-
1053
- def request_failed exception, req, connection # :nodoc:
1054
- due_to = "(due to #{exception.message} - #{exception.class})"
1055
- message = "too many connection resets #{due_to} #{error_message connection}"
1056
-
1057
- finish connection
1058
-
1059
-
1060
- raise Error, message, exception.backtrace
1061
- end
1062
-
1063
- ##
1064
- # Creates a GET request if +req_or_uri+ is a URI and adds headers to the
899
+ # Creates a GET request if +req_or_uri+ is a Bundler::URI and adds headers to the
1065
900
  # request.
1066
901
  #
1067
902
  # Returns the request.
1068
903
 
1069
904
  def request_setup req_or_uri # :nodoc:
1070
- req = if URI === req_or_uri then
905
+ req = if req_or_uri.respond_to? 'request_uri' then
1071
906
  Net::HTTP::Get.new req_or_uri.request_uri
1072
907
  else
1073
908
  req_or_uri
@@ -1090,45 +925,15 @@ class Bundler::Persistent::Net::HTTP::Persistent
1090
925
  end
1091
926
 
1092
927
  ##
1093
- # Shuts down all connections for +thread+.
1094
- #
1095
- # Uses the current thread by default.
1096
- #
1097
- # If you've used Bundler::Persistent::Net::HTTP::Persistent across multiple threads you should
1098
- # call this in each thread when you're done making HTTP requests.
1099
- #
1100
- # *NOTE*: Calling shutdown for another thread can be dangerous!
1101
- #
1102
- # If the thread is still using the connection it may cause an error! It is
1103
- # best to call #shutdown in the thread at the appropriate time instead!
1104
-
1105
- def shutdown thread = Thread.current
1106
- generation = reconnect
1107
- cleanup generation, thread, @generation_key
1108
-
1109
- ssl_generation = reconnect_ssl
1110
- cleanup ssl_generation, thread, @ssl_generation_key
1111
-
1112
- thread[@request_key] = nil
1113
- thread[@timeout_key] = nil
1114
- end
1115
-
1116
- ##
1117
- # Shuts down all connections in all threads
1118
- #
1119
- # *NOTE*: THIS METHOD IS VERY DANGEROUS!
928
+ # Shuts down all connections
1120
929
  #
1121
- # Do not call this method if other threads are still using their
1122
- # connections! Call #shutdown at the appropriate time instead!
930
+ # *NOTE*: Calling shutdown for can be dangerous!
1123
931
  #
1124
- # Use this method only as a last resort!
932
+ # If any thread is still using a connection it may cause an error! Call
933
+ # #shutdown when you are completely done making requests!
1125
934
 
1126
- def shutdown_in_all_threads
1127
- Thread.list.each do |thread|
1128
- shutdown thread
1129
- end
1130
-
1131
- nil
935
+ def shutdown
936
+ @pool.shutdown { |http| http.finish }
1132
937
  end
1133
938
 
1134
939
  ##
@@ -1137,9 +942,14 @@ class Bundler::Persistent::Net::HTTP::Persistent
1137
942
  def ssl connection
1138
943
  connection.use_ssl = true
1139
944
 
945
+ connection.ciphers = @ciphers if @ciphers
946
+ connection.ssl_timeout = @ssl_timeout if @ssl_timeout
1140
947
  connection.ssl_version = @ssl_version if @ssl_version
948
+ connection.min_version = @min_version if @min_version
949
+ connection.max_version = @max_version if @max_version
1141
950
 
1142
- connection.verify_mode = @verify_mode
951
+ connection.verify_depth = @verify_depth
952
+ connection.verify_mode = @verify_mode
1143
953
 
1144
954
  if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
1145
955
  not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
@@ -1168,8 +978,10 @@ application:
1168
978
  WARNING
1169
979
  end
1170
980
 
1171
- if @ca_file then
1172
- connection.ca_file = @ca_file
981
+ connection.ca_file = @ca_file if @ca_file
982
+ connection.ca_path = @ca_path if @ca_path
983
+
984
+ if @ca_file or @ca_path then
1173
985
  connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
1174
986
  connection.verify_callback = @verify_callback if @verify_callback
1175
987
  end
@@ -1189,11 +1001,12 @@ application:
1189
1001
  end
1190
1002
 
1191
1003
  ##
1192
- # Finishes all connections that existed before the given SSL parameter
1193
- # +generation+.
1004
+ # SSL session lifetime
1005
+
1006
+ def ssl_timeout= ssl_timeout
1007
+ @ssl_timeout = ssl_timeout
1194
1008
 
1195
- def ssl_cleanup generation # :nodoc:
1196
- cleanup generation, Thread.current, @ssl_generation_key
1009
+ reconnect_ssl
1197
1010
  end
1198
1011
 
1199
1012
  ##
@@ -1203,7 +1016,34 @@ application:
1203
1016
  @ssl_version = ssl_version
1204
1017
 
1205
1018
  reconnect_ssl
1206
- end if RUBY_VERSION > '1.9'
1019
+ end
1020
+
1021
+ ##
1022
+ # Minimum SSL version to use
1023
+
1024
+ def min_version= min_version
1025
+ @min_version = min_version
1026
+
1027
+ reconnect_ssl
1028
+ end
1029
+
1030
+ ##
1031
+ # maximum SSL version to use
1032
+
1033
+ def max_version= max_version
1034
+ @max_version = max_version
1035
+
1036
+ reconnect_ssl
1037
+ end
1038
+
1039
+ ##
1040
+ # Sets the depth of SSL certificate verification
1041
+
1042
+ def verify_depth= verify_depth
1043
+ @verify_depth = verify_depth
1044
+
1045
+ reconnect_ssl
1046
+ end
1207
1047
 
1208
1048
  ##
1209
1049
  # Sets the HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER.
@@ -1226,8 +1066,8 @@ application:
1226
1066
 
1227
1067
  reconnect_ssl
1228
1068
  end
1229
-
1230
1069
  end
1231
1070
 
1232
- require 'bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse'
1071
+ require_relative 'persistent/connection'
1072
+ require_relative 'persistent/pool'
1233
1073