bundler 1.17.3 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (426) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3354 -1258
  3. data/LICENSE.md +18 -19
  4. data/README.md +10 -15
  5. data/bundler.gemspec +15 -33
  6. data/exe/bundle +8 -10
  7. data/exe/bundler +1 -1
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +5 -13
  10. data/lib/bundler/capistrano.rb +5 -5
  11. data/lib/bundler/checksum.rb +254 -0
  12. data/lib/bundler/ci_detector.rb +75 -0
  13. data/lib/bundler/cli/add.rb +29 -15
  14. data/lib/bundler/cli/binstubs.rb +13 -5
  15. data/lib/bundler/cli/cache.rb +24 -17
  16. data/lib/bundler/cli/check.rb +7 -5
  17. data/lib/bundler/cli/clean.rb +1 -1
  18. data/lib/bundler/cli/common.rb +50 -14
  19. data/lib/bundler/cli/config.rb +171 -86
  20. data/lib/bundler/cli/console.rb +3 -6
  21. data/lib/bundler/cli/doctor.rb +29 -12
  22. data/lib/bundler/cli/exec.rb +9 -25
  23. data/lib/bundler/cli/fund.rb +36 -0
  24. data/lib/bundler/cli/gem.rb +268 -53
  25. data/lib/bundler/cli/info.rb +51 -18
  26. data/lib/bundler/cli/init.rb +7 -3
  27. data/lib/bundler/cli/inject.rb +2 -2
  28. data/lib/bundler/cli/install.rb +55 -73
  29. data/lib/bundler/cli/issue.rb +9 -8
  30. data/lib/bundler/cli/list.rb +19 -11
  31. data/lib/bundler/cli/lock.rb +56 -26
  32. data/lib/bundler/cli/open.rb +10 -7
  33. data/lib/bundler/cli/outdated.rb +159 -128
  34. data/lib/bundler/cli/platform.rb +8 -6
  35. data/lib/bundler/cli/plugin.rb +23 -12
  36. data/lib/bundler/cli/pristine.rb +39 -26
  37. data/lib/bundler/cli/remove.rb +1 -2
  38. data/lib/bundler/cli/show.rb +7 -7
  39. data/lib/bundler/cli/update.rb +51 -19
  40. data/lib/bundler/cli/viz.rb +1 -1
  41. data/lib/bundler/cli.rb +399 -390
  42. data/lib/bundler/compact_index_client/cache.rb +55 -77
  43. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  44. data/lib/bundler/compact_index_client/gem_parser.rb +32 -0
  45. data/lib/bundler/compact_index_client/parser.rb +84 -0
  46. data/lib/bundler/compact_index_client/updater.rb +72 -84
  47. data/lib/bundler/compact_index_client.rb +61 -73
  48. data/lib/bundler/constants.rb +9 -2
  49. data/lib/bundler/current_ruby.rb +20 -21
  50. data/lib/bundler/definition.rb +663 -505
  51. data/lib/bundler/dependency.rb +38 -71
  52. data/lib/bundler/deployment.rb +1 -1
  53. data/lib/bundler/digest.rb +71 -0
  54. data/lib/bundler/dsl.rb +171 -152
  55. data/lib/bundler/endpoint_specification.rb +43 -17
  56. data/lib/bundler/env.rb +11 -18
  57. data/lib/bundler/environment_preserver.rb +17 -8
  58. data/lib/bundler/errors.rb +115 -14
  59. data/lib/bundler/feature_flag.rb +15 -39
  60. data/lib/bundler/fetcher/base.rb +12 -12
  61. data/lib/bundler/fetcher/compact_index.rb +41 -47
  62. data/lib/bundler/fetcher/dependency.rb +4 -8
  63. data/lib/bundler/fetcher/downloader.rb +27 -20
  64. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  65. data/lib/bundler/fetcher/index.rb +6 -33
  66. data/lib/bundler/fetcher.rb +109 -90
  67. data/lib/bundler/force_platform.rb +16 -0
  68. data/lib/bundler/friendly_errors.rb +50 -55
  69. data/lib/bundler/gem_helper.rb +81 -46
  70. data/lib/bundler/gem_helpers.rb +78 -29
  71. data/lib/bundler/gem_tasks.rb +1 -1
  72. data/lib/bundler/gem_version_promoter.rb +68 -109
  73. data/lib/bundler/graph.rb +11 -11
  74. data/lib/bundler/index.rb +74 -82
  75. data/lib/bundler/injector.rb +58 -26
  76. data/lib/bundler/inline.rb +59 -35
  77. data/lib/bundler/installer/gem_installer.rb +29 -29
  78. data/lib/bundler/installer/parallel_installer.rb +38 -68
  79. data/lib/bundler/installer/standalone.rb +76 -16
  80. data/lib/bundler/installer.rb +60 -135
  81. data/lib/bundler/lazy_specification.rb +161 -63
  82. data/lib/bundler/lockfile_generator.rb +14 -5
  83. data/lib/bundler/lockfile_parser.rb +150 -109
  84. data/lib/bundler/man/bundle-add.1 +76 -0
  85. data/lib/bundler/man/bundle-add.1.ronn +87 -0
  86. data/{man → lib/bundler/man}/bundle-binstubs.1 +15 -22
  87. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +8 -7
  88. data/lib/bundler/man/bundle-cache.1 +68 -0
  89. data/lib/bundler/man/bundle-cache.1.ronn +108 -0
  90. data/{man → lib/bundler/man}/bundle-check.1 +7 -14
  91. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +7 -2
  92. data/{man → lib/bundler/man}/bundle-clean.1 +4 -11
  93. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  94. data/{man → lib/bundler/man}/bundle-config.1 +80 -260
  95. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +104 -98
  96. data/lib/bundler/man/bundle-console.1 +33 -0
  97. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  98. data/{man → lib/bundler/man}/bundle-doctor.1 +5 -19
  99. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +1 -1
  100. data/lib/bundler/man/bundle-env.1 +9 -0
  101. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  102. data/{man → lib/bundler/man}/bundle-exec.1 +20 -78
  103. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +12 -10
  104. data/lib/bundler/man/bundle-fund.1 +22 -0
  105. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  106. data/lib/bundler/man/bundle-gem.1 +87 -0
  107. data/lib/bundler/man/bundle-gem.1.ronn +149 -0
  108. data/lib/bundler/man/bundle-help.1 +9 -0
  109. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/lib/bundler/man/bundle-info.1 +17 -0
  111. data/lib/bundler/man/bundle-info.1.ronn +21 -0
  112. data/{man → lib/bundler/man}/bundle-init.1 +8 -13
  113. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +5 -2
  114. data/lib/bundler/man/bundle-inject.1 +31 -0
  115. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +12 -2
  116. data/{man → lib/bundler/man}/bundle-install.1 +65 -155
  117. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +66 -57
  118. data/lib/bundler/man/bundle-issue.1 +45 -0
  119. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  120. data/lib/bundler/man/bundle-licenses.1 +9 -0
  121. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  122. data/{man → lib/bundler/man}/bundle-list.1 +9 -24
  123. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +10 -7
  124. data/{man → lib/bundler/man}/bundle-lock.1 +25 -34
  125. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +25 -4
  126. data/lib/bundler/man/bundle-open.1 +32 -0
  127. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +10 -1
  128. data/{man → lib/bundler/man}/bundle-outdated.1 +23 -75
  129. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +21 -22
  130. data/lib/bundler/man/bundle-platform.1 +49 -0
  131. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  132. data/lib/bundler/man/bundle-plugin.1 +58 -0
  133. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  134. data/{man → lib/bundler/man}/bundle-pristine.1 +5 -16
  135. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +1 -1
  136. data/{man → lib/bundler/man}/bundle-remove.1 +4 -14
  137. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +1 -1
  138. data/{man → lib/bundler/man}/bundle-show.1 +7 -11
  139. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +4 -0
  140. data/{man → lib/bundler/man}/bundle-update.1 +35 -148
  141. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +21 -12
  142. data/lib/bundler/man/bundle-version.1 +22 -0
  143. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  144. data/{man → lib/bundler/man}/bundle-viz.1 +9 -18
  145. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +9 -3
  146. data/{man → lib/bundler/man}/bundle.1 +19 -53
  147. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  148. data/{man → lib/bundler/man}/gemfile.5 +139 -356
  149. data/{man → lib/bundler/man}/gemfile.5.ronn +134 -97
  150. data/{man → lib/bundler/man}/index.txt +9 -1
  151. data/lib/bundler/match_metadata.rb +17 -0
  152. data/lib/bundler/match_platform.rb +2 -3
  153. data/lib/bundler/match_remote_metadata.rb +29 -0
  154. data/lib/bundler/materialization.rb +59 -0
  155. data/lib/bundler/mirror.rb +10 -12
  156. data/lib/bundler/plugin/api/source.rb +34 -18
  157. data/lib/bundler/plugin/api.rb +1 -1
  158. data/lib/bundler/plugin/dsl.rb +1 -1
  159. data/lib/bundler/plugin/events.rb +24 -0
  160. data/lib/bundler/plugin/index.rb +44 -9
  161. data/lib/bundler/plugin/installer/git.rb +0 -4
  162. data/lib/bundler/plugin/installer/path.rb +18 -0
  163. data/lib/bundler/plugin/installer/rubygems.rb +1 -9
  164. data/lib/bundler/plugin/installer.rb +63 -27
  165. data/lib/bundler/plugin/source_list.rb +5 -1
  166. data/lib/bundler/plugin.rb +131 -45
  167. data/lib/bundler/process_lock.rb +10 -14
  168. data/lib/bundler/remote_specification.rb +22 -10
  169. data/lib/bundler/resolver/base.rb +118 -0
  170. data/lib/bundler/resolver/candidate.rb +82 -0
  171. data/lib/bundler/resolver/incompatibility.rb +15 -0
  172. data/lib/bundler/resolver/package.rb +90 -0
  173. data/lib/bundler/resolver/root.rb +25 -0
  174. data/lib/bundler/resolver/spec_group.rb +60 -68
  175. data/lib/bundler/resolver.rb +454 -303
  176. data/lib/bundler/retry.rb +6 -6
  177. data/lib/bundler/ruby_dsl.rb +51 -7
  178. data/lib/bundler/ruby_version.rb +23 -38
  179. data/lib/bundler/rubygems_ext.rb +357 -98
  180. data/lib/bundler/rubygems_gem_installer.rb +131 -65
  181. data/lib/bundler/rubygems_integration.rb +149 -591
  182. data/lib/bundler/runtime.rb +51 -51
  183. data/lib/bundler/safe_marshal.rb +31 -0
  184. data/lib/bundler/self_manager.rb +206 -0
  185. data/lib/bundler/settings.rb +271 -135
  186. data/lib/bundler/setup.rb +23 -12
  187. data/lib/bundler/shared_helpers.rb +127 -117
  188. data/lib/bundler/similarity_detector.rb +3 -3
  189. data/lib/bundler/source/git/git_proxy.rb +326 -127
  190. data/lib/bundler/source/git.rb +207 -88
  191. data/lib/bundler/source/metadata.rb +19 -18
  192. data/lib/bundler/source/path/installer.rb +11 -32
  193. data/lib/bundler/source/path.rb +39 -38
  194. data/lib/bundler/source/rubygems/remote.rb +3 -4
  195. data/lib/bundler/source/rubygems.rb +223 -255
  196. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  197. data/lib/bundler/source.rb +33 -11
  198. data/lib/bundler/source_list.rb +131 -66
  199. data/lib/bundler/source_map.rb +71 -0
  200. data/lib/bundler/spec_set.rb +239 -94
  201. data/lib/bundler/stub_specification.rb +77 -39
  202. data/lib/bundler/templates/Executable +3 -5
  203. data/lib/bundler/templates/Executable.bundler +23 -19
  204. data/lib/bundler/templates/Executable.standalone +4 -4
  205. data/lib/bundler/templates/Gemfile +0 -2
  206. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  207. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +104 -46
  208. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  209. data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
  210. data/lib/bundler/templates/newgem/README.md.tt +18 -16
  211. data/lib/bundler/templates/newgem/Rakefile.tt +44 -6
  212. data/lib/bundler/templates/newgem/bin/console.tt +1 -4
  213. data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  214. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  215. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  216. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  217. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  218. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  219. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  220. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  221. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  222. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  223. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  224. data/lib/bundler/templates/newgem/newgem.gemspec.tt +37 -40
  225. data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  226. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  227. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  228. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  229. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  230. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  231. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  232. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  233. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  234. data/lib/bundler/ui/rg_proxy.rb +2 -2
  235. data/lib/bundler/ui/shell.rb +64 -23
  236. data/lib/bundler/ui/silent.rb +33 -6
  237. data/lib/bundler/ui.rb +3 -3
  238. data/lib/bundler/uri_credentials_filter.rb +11 -5
  239. data/lib/bundler/uri_normalizer.rb +23 -0
  240. data/lib/bundler/vendor/.document +1 -0
  241. data/lib/bundler/vendor/connection_pool/.document +1 -0
  242. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  243. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  244. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  245. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  246. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +175 -0
  247. data/lib/bundler/vendor/fileutils/.document +1 -0
  248. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  249. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1490 -432
  250. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  251. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  252. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  253. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  254. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  255. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +362 -484
  256. data/lib/bundler/vendor/pub_grub/.document +1 -0
  257. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  258. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  259. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  260. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  261. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  262. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  263. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  264. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  265. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  266. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  267. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  268. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  269. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  270. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  271. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  272. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  273. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  274. data/lib/bundler/vendor/securerandom/.document +1 -0
  275. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  276. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  277. data/lib/bundler/vendor/thor/.document +1 -0
  278. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  279. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +4 -3
  280. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  281. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +8 -18
  282. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  283. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +27 -20
  284. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +34 -13
  285. data/lib/bundler/vendor/thor/lib/thor/actions.rb +47 -28
  286. data/lib/bundler/vendor/thor/lib/thor/base.rb +200 -54
  287. data/lib/bundler/vendor/thor/lib/thor/command.rb +34 -18
  288. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  289. data/lib/bundler/vendor/thor/lib/thor/error.rb +74 -0
  290. data/lib/bundler/vendor/thor/lib/thor/group.rb +15 -4
  291. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +2 -1
  292. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  293. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  294. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  295. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  296. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
  297. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +35 -15
  298. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +45 -13
  299. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +86 -13
  300. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  301. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +3 -2
  302. data/lib/bundler/vendor/thor/lib/thor/runner.rb +51 -40
  303. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +99 -148
  304. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -43
  305. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  306. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -49
  307. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  308. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  309. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  310. data/lib/bundler/vendor/thor/lib/thor/shell.rb +6 -6
  311. data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
  312. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  313. data/lib/bundler/vendor/thor/lib/thor.rb +182 -17
  314. data/lib/bundler/vendor/tsort/.document +1 -0
  315. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  316. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  317. data/lib/bundler/vendor/uri/.document +1 -0
  318. data/lib/bundler/vendor/uri/COPYING +56 -0
  319. data/lib/bundler/vendor/uri/lib/uri/common.rb +876 -0
  320. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  321. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  322. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1578 -0
  323. data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  324. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  325. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  326. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  327. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  328. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  329. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  330. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  331. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  332. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  333. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  334. data/lib/bundler/vendored_fileutils.rb +1 -6
  335. data/lib/bundler/vendored_net_http.rb +23 -0
  336. data/lib/bundler/vendored_persistent.rb +1 -42
  337. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  338. data/lib/bundler/vendored_securerandom.rb +12 -0
  339. data/lib/bundler/vendored_thor.rb +2 -2
  340. data/lib/bundler/vendored_timeout.rb +12 -0
  341. data/lib/bundler/vendored_tsort.rb +4 -0
  342. data/lib/bundler/vendored_uri.rb +21 -0
  343. data/lib/bundler/version.rb +5 -20
  344. data/lib/bundler/vlad.rb +3 -3
  345. data/lib/bundler/worker.rb +26 -15
  346. data/lib/bundler/yaml_serializer.rb +21 -13
  347. data/lib/bundler.rb +364 -230
  348. metadata +186 -218
  349. data/exe/bundle_ruby +0 -60
  350. data/lib/bundler/cli/package.rb +0 -49
  351. data/lib/bundler/compatibility_guard.rb +0 -14
  352. data/lib/bundler/dep_proxy.rb +0 -48
  353. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  354. data/lib/bundler/gemdeps.rb +0 -29
  355. data/lib/bundler/psyched_yaml.rb +0 -37
  356. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  357. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  358. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  359. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  360. data/lib/bundler/templates/gems.rb +0 -8
  361. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  362. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  363. data/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  364. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  365. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  366. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  367. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  368. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  369. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  370. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  371. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  372. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  373. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  374. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  375. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  376. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  377. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  378. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  379. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  380. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  381. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  382. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  383. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  384. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  385. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  386. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  387. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  388. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  389. data/lib/bundler/version_ranges.rb +0 -76
  390. data/man/bundle-add.1 +0 -58
  391. data/man/bundle-add.1.txt +0 -52
  392. data/man/bundle-add.ronn +0 -40
  393. data/man/bundle-binstubs.1.txt +0 -48
  394. data/man/bundle-check.1.txt +0 -33
  395. data/man/bundle-clean.1.txt +0 -26
  396. data/man/bundle-config.1.txt +0 -529
  397. data/man/bundle-doctor.1.txt +0 -44
  398. data/man/bundle-exec.1.txt +0 -178
  399. data/man/bundle-gem.1 +0 -80
  400. data/man/bundle-gem.1.txt +0 -91
  401. data/man/bundle-gem.ronn +0 -78
  402. data/man/bundle-info.1 +0 -20
  403. data/man/bundle-info.1.txt +0 -21
  404. data/man/bundle-info.ronn +0 -17
  405. data/man/bundle-init.1.txt +0 -34
  406. data/man/bundle-inject.1 +0 -33
  407. data/man/bundle-inject.1.txt +0 -32
  408. data/man/bundle-install.1.txt +0 -396
  409. data/man/bundle-list.1.txt +0 -43
  410. data/man/bundle-lock.1.txt +0 -93
  411. data/man/bundle-open.1 +0 -32
  412. data/man/bundle-open.1.txt +0 -29
  413. data/man/bundle-outdated.1.txt +0 -131
  414. data/man/bundle-package.1 +0 -55
  415. data/man/bundle-package.1.txt +0 -79
  416. data/man/bundle-package.ronn +0 -72
  417. data/man/bundle-platform.1 +0 -61
  418. data/man/bundle-platform.1.txt +0 -57
  419. data/man/bundle-pristine.1.txt +0 -44
  420. data/man/bundle-remove.1.txt +0 -34
  421. data/man/bundle-show.1.txt +0 -27
  422. data/man/bundle-update.1.txt +0 -391
  423. data/man/bundle-viz.1.txt +0 -39
  424. data/man/bundle.1.txt +0 -116
  425. data/man/gemfile.5.txt +0 -653
  426. /data/lib/bundler/{ssl_certs → man}/.document +0 -0
@@ -1,88 +1,80 @@
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'
1
+ require_relative '../../../../../vendored_net_http'
2
+ require_relative '../../../../../vendored_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
 
18
8
  ##
19
- # Persistent connections for Net::HTTP
9
+ # Persistent connections for Gem::Net::HTTP
20
10
  #
21
- # Bundler::Persistent::Net::HTTP::Persistent maintains persistent connections across all the
11
+ # Gem::Net::HTTP::Persistent maintains persistent connections across all the
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 = Gem::URI 'http://example.com/awesome/web/service'
40
26
  #
41
- # http = Bundler::Persistent::Net::HTTP::Persistent.new 'my_app_name'
27
+ # http = Gem::Net::HTTP::Persistent.new
42
28
  #
43
29
  # # perform a GET
44
30
  # response = http.request uri
45
31
  #
46
32
  # # or
47
33
  #
48
- # get = Net::HTTP::Get.new uri.request_uri
34
+ # get = Gem::Net::HTTP::Get.new uri.request_uri
49
35
  # response = http.request get
50
36
  #
51
37
  # # create a POST
52
38
  # post_uri = uri + 'create'
53
- # post = Net::HTTP::Post.new post_uri.path
39
+ # post = Gem::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 Gem::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 Gem::URI#request_uri not Gem::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
+ # Gem::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
71
+ # #verify_hostname :: Use hostname verification for server certificate
72
+ # during the handshake
81
73
  #
82
74
  # == Proxies
83
75
  #
84
76
  # 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
77
+ # second argument to ::new. The proxy may be the Gem::URI of the proxy server or
86
78
  # <code>:ENV</code> which will consult environment variables.
87
79
  #
88
80
  # See #proxy= and #proxy_from_env for details.
@@ -102,14 +94,15 @@ autoload :OpenSSL, 'openssl'
102
94
  #
103
95
  # === Segregation
104
96
  #
105
- # By providing an application name to ::new you can separate your connections
106
- # from the connections of other applications.
97
+ # Each Gem::Net::HTTP::Persistent instance has its own pool of connections. There
98
+ # is no sharing with other instances (as was true in earlier versions).
107
99
  #
108
100
  # === Idle Timeout
109
101
  #
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.
102
+ # If a connection hasn't been used for this number of seconds it will
103
+ # automatically be reset upon the next use to avoid attempting to send to a
104
+ # closed connection. The default value is 5 seconds. nil means no timeout.
105
+ # Set through #idle_timeout.
113
106
  #
114
107
  # Reducing this value may help avoid the "too many connection resets" error
115
108
  # when sending non-idempotent requests while increasing this value will cause
@@ -124,8 +117,9 @@ autoload :OpenSSL, 'openssl'
124
117
  #
125
118
  # The number of requests that should be made before opening a new connection.
126
119
  # 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.
120
+ # 101st request will fail with ECONNRESET. If unset (default), this value has
121
+ # no effect, if set, connections will be reset on the request after
122
+ # max_requests.
129
123
  #
130
124
  # === Open Timeout
131
125
  #
@@ -137,48 +131,9 @@ autoload :OpenSSL, 'openssl'
137
131
  # Socket options may be set on newly-created connections. See #socket_options
138
132
  # for details.
139
133
  #
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
134
  # === Connection Termination
180
135
  #
181
- # If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
136
+ # If you are done using the Gem::Net::HTTP::Persistent instance you may shut down
182
137
  # all the connections in the current thread with #shutdown. This is not
183
138
  # recommended for normal use, it should only be used when it will be several
184
139
  # minutes before you make another HTTP request.
@@ -188,7 +143,7 @@ autoload :OpenSSL, 'openssl'
188
143
  # Ruby will automatically garbage collect and shutdown your HTTP connections
189
144
  # when the thread terminates.
190
145
 
191
- class Bundler::Persistent::Net::HTTP::Persistent
146
+ class Gem::Net::HTTP::Persistent
192
147
 
193
148
  ##
194
149
  # The beginning of Time
@@ -201,27 +156,30 @@ class Bundler::Persistent::Net::HTTP::Persistent
201
156
  HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc:
202
157
 
203
158
  ##
204
- # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
159
+ # The default connection pool size is 1/4 the allowed open files
160
+ # (<code>ulimit -n</code>) or 256 if your OS does not support file handle
161
+ # limits (typically windows).
205
162
 
206
- VERSION = '2.9.4'
163
+ if Process.const_defined? :RLIMIT_NOFILE
164
+ open_file_limits = Process.getrlimit(Process::RLIMIT_NOFILE)
165
+
166
+ # Under JRuby on Windows Process responds to `getrlimit` but returns something that does not match docs
167
+ if open_file_limits.respond_to?(:first)
168
+ DEFAULT_POOL_SIZE = open_file_limits.first / 4
169
+ else
170
+ DEFAULT_POOL_SIZE = 256
171
+ end
172
+ else
173
+ DEFAULT_POOL_SIZE = 256
174
+ end
207
175
 
208
176
  ##
209
- # Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
210
- # the exception list for ruby 1.x.
177
+ # The version of Gem::Net::HTTP::Persistent you are using
211
178
 
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
179
+ VERSION = '4.0.4'
222
180
 
223
181
  ##
224
- # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
182
+ # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
225
183
  # SystemCallErrors are re-raised with a human-readable message under this
226
184
  # class.
227
185
 
@@ -241,38 +199,38 @@ class Bundler::Persistent::Net::HTTP::Persistent
241
199
  # NOTE: This may not work on ruby > 1.9.
242
200
 
243
201
  def self.detect_idle_timeout uri, max = 10
244
- uri = URI uri unless URI::Generic === uri
202
+ uri = Gem::URI uri unless Gem::URI::Generic === uri
245
203
  uri += '/'
246
204
 
247
- req = Net::HTTP::Head.new uri.request_uri
205
+ req = Gem::Net::HTTP::Head.new uri.request_uri
248
206
 
249
207
  http = new 'net-http-persistent detect_idle_timeout'
250
208
 
251
- connection = http.connection_for uri
209
+ http.connection_for uri do |connection|
210
+ sleep_time = 0
252
211
 
253
- sleep_time = 0
212
+ http = connection.http
254
213
 
255
- loop do
256
- response = connection.request req
214
+ loop do
215
+ response = http.request req
257
216
 
258
- $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
217
+ $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
259
218
 
260
- unless Net::HTTPOK === response then
261
- raise Error, "bad response code #{response.code} detecting idle timeout"
262
- end
219
+ unless Gem::Net::HTTPOK === response then
220
+ raise Error, "bad response code #{response.code} detecting idle timeout"
221
+ end
263
222
 
264
- break if sleep_time >= max
223
+ break if sleep_time >= max
265
224
 
266
- sleep_time += 1
225
+ sleep_time += 1
267
226
 
268
- $stderr.puts "sleeping #{sleep_time}" if $DEBUG
269
- sleep sleep_time
227
+ $stderr.puts "sleeping #{sleep_time}" if $DEBUG
228
+ sleep sleep_time
229
+ end
270
230
  end
271
231
  rescue
272
232
  # ignore StandardErrors, we've probably found the idle timeout.
273
233
  ensure
274
- http.shutdown
275
-
276
234
  return sleep_time unless $!
277
235
  end
278
236
 
@@ -281,7 +239,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
281
239
 
282
240
  attr_reader :certificate
283
241
 
284
- # For Net::HTTP parity
242
+ ##
243
+ # For Gem::Net::HTTP parity
244
+
285
245
  alias cert certificate
286
246
 
287
247
  ##
@@ -290,6 +250,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
290
250
 
291
251
  attr_reader :ca_file
292
252
 
253
+ ##
254
+ # A directory of SSL certificates to be used as certificate authorities.
255
+ # Setting this will set verify_mode to VERIFY_PEER.
256
+
257
+ attr_reader :ca_path
258
+
293
259
  ##
294
260
  # An SSL certificate store. Setting this will override the default
295
261
  # certificate store. See verify_mode for more information.
@@ -297,7 +263,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
297
263
  attr_reader :cert_store
298
264
 
299
265
  ##
300
- # Sends debug_output to this IO via Net::HTTP#set_debug_output.
266
+ # The ciphers allowed for SSL connections
267
+
268
+ attr_reader :ciphers
269
+
270
+ ##
271
+ # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
301
272
  #
302
273
  # Never use this method in production code, it causes a serious security
303
274
  # hole.
@@ -310,12 +281,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
310
281
  attr_reader :generation # :nodoc:
311
282
 
312
283
  ##
313
- # Where this instance's connections live in the thread local variables
314
-
315
- attr_reader :generation_key # :nodoc:
316
-
317
- ##
318
- # Headers that are added to every request using Net::HTTP#add_field
284
+ # Headers that are added to every request using Gem::Net::HTTP#add_field
319
285
 
320
286
  attr_reader :headers
321
287
 
@@ -337,6 +303,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
337
303
 
338
304
  attr_accessor :max_requests
339
305
 
306
+ ##
307
+ # Number of retries to perform if a request fails.
308
+ #
309
+ # See also #max_retries=, Gem::Net::HTTP#max_retries=.
310
+
311
+ attr_reader :max_retries
312
+
340
313
  ##
341
314
  # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
342
315
  # HTTP/1.1 servers.
@@ -349,18 +322,17 @@ class Bundler::Persistent::Net::HTTP::Persistent
349
322
  attr_accessor :keep_alive
350
323
 
351
324
  ##
352
- # A name for this connection. Allows you to keep your connections apart
353
- # from everybody else's.
325
+ # The name for this collection of persistent connections.
354
326
 
355
327
  attr_reader :name
356
328
 
357
329
  ##
358
- # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
330
+ # Seconds to wait until a connection is opened. See Gem::Net::HTTP#open_timeout
359
331
 
360
332
  attr_accessor :open_timeout
361
333
 
362
334
  ##
363
- # Headers that are added to every request using Net::HTTP#[]=
335
+ # Headers that are added to every request using Gem::Net::HTTP#[]=
364
336
 
365
337
  attr_reader :override_headers
366
338
 
@@ -369,7 +341,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
369
341
 
370
342
  attr_reader :private_key
371
343
 
372
- # For Net::HTTP parity
344
+ ##
345
+ # For Gem::Net::HTTP parity
346
+
373
347
  alias key private_key
374
348
 
375
349
  ##
@@ -383,14 +357,19 @@ class Bundler::Persistent::Net::HTTP::Persistent
383
357
  attr_reader :no_proxy
384
358
 
385
359
  ##
386
- # Seconds to wait until reading one block. See Net::HTTP#read_timeout
360
+ # Test-only accessor for the connection pool
361
+
362
+ attr_reader :pool # :nodoc:
363
+
364
+ ##
365
+ # Seconds to wait until reading one block. See Gem::Net::HTTP#read_timeout
387
366
 
388
367
  attr_accessor :read_timeout
389
368
 
390
369
  ##
391
- # Where this instance's request counts live in the thread local variables
370
+ # Seconds to wait until writing one block. See Gem::Net::HTTP#write_timeout
392
371
 
393
- attr_reader :request_key # :nodoc:
372
+ attr_accessor :write_timeout
394
373
 
395
374
  ##
396
375
  # By default SSL sessions are reused to avoid extra SSL handshakes. Set
@@ -418,17 +397,33 @@ class Bundler::Persistent::Net::HTTP::Persistent
418
397
  attr_reader :ssl_generation # :nodoc:
419
398
 
420
399
  ##
421
- # Where this instance's SSL connections live in the thread local variables
400
+ # SSL session lifetime
422
401
 
423
- attr_reader :ssl_generation_key # :nodoc:
402
+ attr_reader :ssl_timeout
424
403
 
425
404
  ##
426
405
  # SSL version to use.
427
406
  #
428
407
  # By default, the version will be negotiated automatically between client
429
- # and server. Ruby 1.9 and newer only.
408
+ # and server. Ruby 1.9 and newer only. Deprecated since Ruby 2.5.
409
+
410
+ attr_reader :ssl_version
411
+
412
+ ##
413
+ # Minimum SSL version to use, e.g. :TLS1_1
414
+ #
415
+ # By default, the version will be negotiated automatically between client
416
+ # and server. Ruby 2.5 and newer only.
417
+
418
+ attr_reader :min_version
419
+
420
+ ##
421
+ # Maximum SSL version to use, e.g. :TLS1_2
422
+ #
423
+ # By default, the version will be negotiated automatically between client
424
+ # and server. Ruby 2.5 and newer only.
430
425
 
431
- attr_reader :ssl_version if RUBY_VERSION > '1.9'
426
+ attr_reader :max_version
432
427
 
433
428
  ##
434
429
  # Where this instance's last-use times live in the thread local variables
@@ -436,50 +431,63 @@ class Bundler::Persistent::Net::HTTP::Persistent
436
431
  attr_reader :timeout_key # :nodoc:
437
432
 
438
433
  ##
439
- # SSL verification callback. Used when ca_file is set.
434
+ # SSL verification callback. Used when ca_file or ca_path is set.
440
435
 
441
436
  attr_reader :verify_callback
442
437
 
438
+ ##
439
+ # Sets the depth of SSL certificate verification
440
+
441
+ attr_reader :verify_depth
442
+
443
443
  ##
444
444
  # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER which verifies
445
445
  # the server certificate.
446
446
  #
447
- # If no ca_file or cert_store is set the default system certificate store is
448
- # used.
447
+ # If no ca_file, ca_path or cert_store is set the default system certificate
448
+ # store is used.
449
449
  #
450
450
  # You can use +verify_mode+ to override any default values.
451
451
 
452
452
  attr_reader :verify_mode
453
453
 
454
454
  ##
455
- # Enable retries of non-idempotent requests that change data (e.g. POST
456
- # requests) when the server has disconnected.
455
+ # HTTPS verify_hostname.
456
+ #
457
+ # If a client sets this to true and enables SNI with SSLSocket#hostname=,
458
+ # the hostname verification on the server certificate is performed
459
+ # automatically during the handshake using
460
+ # OpenSSL::SSL.verify_certificate_identity().
457
461
  #
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
+ # You can set +verify_hostname+ as true to use hostname verification
463
+ # during the handshake.
464
+ #
465
+ # NOTE: This works with Ruby > 3.0.
462
466
 
463
- attr_accessor :retry_change_requests
467
+ attr_reader :verify_hostname
464
468
 
465
469
  ##
466
- # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
470
+ # Creates a new Gem::Net::HTTP::Persistent.
467
471
  #
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.
472
+ # Set a +name+ for fun. Your library name should be good enough, but this
473
+ # otherwise has no purpose.
471
474
  #
472
- # +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
475
+ # +proxy+ may be set to a Gem::URI::HTTP or :ENV to pick up proxy options from
473
476
  # the environment. See proxy_from_env for details.
474
477
  #
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:
478
+ # In order to use a Gem::URI for the proxy you may need to do some extra work
479
+ # beyond Gem::URI parsing if the proxy requires a password:
477
480
  #
478
- # proxy = URI 'http://proxy.example'
481
+ # proxy = Gem::URI 'http://proxy.example'
479
482
  # proxy.user = 'AzureDiamond'
480
483
  # proxy.password = 'hunter2'
484
+ #
485
+ # Set +pool_size+ to limit the maximum number of connections allowed.
486
+ # Defaults to 1/4 the number of allowed file handles or 256 if your OS does
487
+ # not support a limit on allowed file handles. You can have no more than
488
+ # this many threads with active HTTP transactions.
481
489
 
482
- def initialize name = nil, proxy = nil
490
+ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
483
491
  @name = name
484
492
 
485
493
  @debug_output = nil
@@ -491,40 +499,42 @@ class Bundler::Persistent::Net::HTTP::Persistent
491
499
  @keep_alive = 30
492
500
  @open_timeout = nil
493
501
  @read_timeout = nil
502
+ @write_timeout = nil
494
503
  @idle_timeout = 5
495
504
  @max_requests = nil
505
+ @max_retries = 1
496
506
  @socket_options = []
507
+ @ssl_generation = 0 # incremented when SSL session variables change
497
508
 
498
509
  @socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
499
510
  Socket.const_defined? :TCP_NODELAY
500
511
 
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
512
+ @pool = Gem::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
513
+ Gem::Net::HTTP::Persistent::Connection.new Gem::Net::HTTP, http_args, @ssl_generation
514
+ end
506
515
 
507
516
  @certificate = nil
508
517
  @ca_file = nil
518
+ @ca_path = nil
519
+ @ciphers = nil
509
520
  @private_key = nil
521
+ @ssl_timeout = nil
510
522
  @ssl_version = nil
523
+ @min_version = nil
524
+ @max_version = nil
511
525
  @verify_callback = nil
526
+ @verify_depth = nil
512
527
  @verify_mode = nil
528
+ @verify_hostname = nil
513
529
  @cert_store = nil
514
530
 
515
- @generation = 0 # incremented when proxy URI changes
516
- @ssl_generation = 0 # incremented when SSL session variables change
531
+ @generation = 0 # incremented when proxy Gem::URI changes
517
532
 
518
533
  if HAVE_OPENSSL then
519
534
  @verify_mode = OpenSSL::SSL::VERIFY_PEER
520
535
  @reuse_ssl_sessions = OpenSSL::SSL.const_defined? :Session
521
536
  end
522
537
 
523
- @retry_change_requests = false
524
-
525
- @ruby_1 = RUBY_VERSION < '2'
526
- @retried_on_ruby_2 = !@ruby_1
527
-
528
538
  self.proxy = proxy if proxy
529
539
  end
530
540
 
@@ -537,7 +547,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
537
547
  reconnect_ssl
538
548
  end
539
549
 
540
- # For Net::HTTP parity
550
+ # For Gem::Net::HTTP parity
541
551
  alias cert= certificate=
542
552
 
543
553
  ##
@@ -549,6 +559,15 @@ class Bundler::Persistent::Net::HTTP::Persistent
549
559
  reconnect_ssl
550
560
  end
551
561
 
562
+ ##
563
+ # Sets the SSL certificate authority path.
564
+
565
+ def ca_path= path
566
+ @ca_path = path
567
+
568
+ reconnect_ssl
569
+ end
570
+
552
571
  ##
553
572
  # Overrides the default SSL certificate store used for verifying
554
573
  # connections.
@@ -560,117 +579,84 @@ class Bundler::Persistent::Net::HTTP::Persistent
560
579
  end
561
580
 
562
581
  ##
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.
567
-
568
- def cleanup(generation, thread = Thread.current,
569
- generation_key = @generation_key) # :nodoc:
570
- timeouts = thread[@timeout_key]
582
+ # The ciphers allowed for SSL connections
571
583
 
572
- (0...generation).each do |old_generation|
573
- next unless thread[generation_key]
584
+ def ciphers= ciphers
585
+ @ciphers = ciphers
574
586
 
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
587
+ reconnect_ssl
583
588
  end
584
589
 
585
590
  ##
586
591
  # Creates a new connection for +uri+
587
592
 
588
593
  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
594
  use_ssl = uri.scheme.downcase == 'https'
595
595
 
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 ':'
596
+ net_http_args = [uri.hostname, uri.port]
615
597
 
598
+ # I'm unsure if uri.host or uri.hostname should be checked against
599
+ # the proxy bypass list.
616
600
  if @proxy_uri and not proxy_bypass? uri.host, uri.port then
617
- connection_id << @proxy_connection_id
618
601
  net_http_args.concat @proxy_args
619
602
  else
620
603
  net_http_args.concat [nil, nil, nil, nil]
621
604
  end
622
605
 
623
- connection = connections[connection_id]
606
+ connection = @pool.checkout net_http_args
624
607
 
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
608
+ http = connection.http
609
+
610
+ connection.ressl @ssl_generation if
611
+ connection.ssl_generation != @ssl_generation
632
612
 
633
- start connection unless connection.started?
613
+ if not http.started? then
614
+ ssl http if use_ssl
615
+ start http
616
+ elsif expired? connection then
617
+ reset connection
618
+ end
634
619
 
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=)
620
+ http.keep_alive_timeout = @idle_timeout if @idle_timeout
621
+ http.max_retries = @max_retries if http.respond_to?(:max_retries=)
622
+ http.read_timeout = @read_timeout if @read_timeout
623
+ http.write_timeout = @write_timeout if
624
+ @write_timeout && http.respond_to?(:write_timeout=)
637
625
 
638
- connection
626
+ return yield connection
639
627
  rescue Errno::ECONNREFUSED
640
- address = connection.proxy_address || connection.address
641
- port = connection.proxy_port || connection.port
628
+ if http.proxy?
629
+ address = http.proxy_address
630
+ port = http.proxy_port
631
+ else
632
+ address = http.address
633
+ port = http.port
634
+ end
642
635
 
643
636
  raise Error, "connection refused: #{address}:#{port}"
644
637
  rescue Errno::EHOSTDOWN
645
- address = connection.proxy_address || connection.address
646
- port = connection.proxy_port || connection.port
638
+ if http.proxy?
639
+ address = http.proxy_address
640
+ port = http.proxy_port
641
+ else
642
+ address = http.address
643
+ port = http.port
644
+ end
647
645
 
648
646
  raise Error, "host down: #{address}:#{port}"
647
+ ensure
648
+ @pool.checkin net_http_args
649
649
  end
650
650
 
651
651
  ##
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
652
+ # CGI::escape wrapper
667
653
 
668
654
  def escape str
669
655
  CGI.escape str if str
670
656
  end
671
657
 
672
658
  ##
673
- # URI::unescape wrapper
659
+ # CGI::unescape wrapper
674
660
 
675
661
  def unescape str
676
662
  CGI.unescape str if str
@@ -682,26 +668,23 @@ class Bundler::Persistent::Net::HTTP::Persistent
682
668
  # maximum request count, false otherwise.
683
669
 
684
670
  def expired? connection
685
- requests = Thread.current[@request_key][connection.object_id]
686
- return true if @max_requests && requests >= @max_requests
671
+ return true if @max_requests && connection.requests >= @max_requests
687
672
  return false unless @idle_timeout
688
673
  return true if @idle_timeout.zero?
689
674
 
690
- last_used = Thread.current[@timeout_key][connection.object_id]
691
-
692
- Time.now - last_used > @idle_timeout
675
+ Time.now - connection.last_use > @idle_timeout
693
676
  end
694
677
 
695
678
  ##
696
- # Starts the Net::HTTP +connection+
679
+ # Starts the Gem::Net::HTTP +connection+
697
680
 
698
- def start connection
699
- connection.set_debug_output @debug_output if @debug_output
700
- connection.open_timeout = @open_timeout if @open_timeout
681
+ def start http
682
+ http.set_debug_output @debug_output if @debug_output
683
+ http.open_timeout = @open_timeout if @open_timeout
701
684
 
702
- connection.start
685
+ http.start
703
686
 
704
- socket = connection.instance_variable_get :@socket
687
+ socket = http.instance_variable_get :@socket
705
688
 
706
689
  if socket then # for fakeweb
707
690
  @socket_options.each do |option|
@@ -711,98 +694,21 @@ class Bundler::Persistent::Net::HTTP::Persistent
711
694
  end
712
695
 
713
696
  ##
714
- # Finishes the Net::HTTP +connection+
715
-
716
- def finish connection, thread = Thread.current
717
- if requests = thread[@request_key] then
718
- requests.delete connection.object_id
719
- end
697
+ # Finishes the Gem::Net::HTTP +connection+
720
698
 
699
+ def finish connection
721
700
  connection.finish
722
- rescue IOError
723
- end
724
701
 
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
702
+ connection.http.instance_variable_set :@last_communicated, nil
703
+ connection.http.instance_variable_set :@ssl_session, nil unless
704
+ @reuse_ssl_sessions
735
705
  end
736
706
 
737
707
  ##
738
708
  # Returns the HTTP protocol version for +uri+
739
709
 
740
710
  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
711
+ @http_versions["#{uri.hostname}:#{uri.port}"]
806
712
  end
807
713
 
808
714
  ##
@@ -813,20 +719,20 @@ class Bundler::Persistent::Net::HTTP::Persistent
813
719
  end
814
720
 
815
721
  ##
816
- # Pipelines +requests+ to the HTTP server at +uri+ yielding responses if a
817
- # block is given. Returns all responses received.
722
+ # Set the maximum number of retries for a request.
818
723
  #
819
- # See
820
- # Net::HTTP::Pipeline[http://docs.seattlerb.org/net-http-pipeline/Net/HTTP/Pipeline.html]
821
- # for further details.
724
+ # Defaults to one retry.
822
725
  #
823
- # Only if <tt>net-http-pipeline</tt> was required before
824
- # <tt>net-http-persistent</tt> #pipeline will be present.
726
+ # Set this to 0 to disable retries.
727
+
728
+ def max_retries= retries
729
+ retries = retries.to_int
825
730
 
826
- def pipeline uri, requests, &block # :yields: responses
827
- connection = connection_for uri
731
+ raise ArgumentError, "max_retries must be positive" if retries < 0
828
732
 
829
- connection.pipeline requests, &block
733
+ @max_retries = retries
734
+
735
+ reconnect
830
736
  end
831
737
 
832
738
  ##
@@ -838,16 +744,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
838
744
  reconnect_ssl
839
745
  end
840
746
 
841
- # For Net::HTTP parity
747
+ # For Gem::Net::HTTP parity
842
748
  alias key= private_key=
843
749
 
844
750
  ##
845
- # Sets the proxy server. The +proxy+ may be the URI of the proxy server,
751
+ # Sets the proxy server. The +proxy+ may be the Gem::URI of the proxy server,
846
752
  # the symbol +:ENV+ which will read the proxy from the environment or nil to
847
753
  # disable use of a proxy. See #proxy_from_env for details on setting the
848
754
  # proxy from the environment.
849
755
  #
850
- # If the proxy URI is set after requests have been made, the next request
756
+ # If the proxy Gem::URI is set after requests have been made, the next request
851
757
  # will shut-down and re-open all connections.
852
758
  #
853
759
  # The +no_proxy+ query parameter can be used to specify hosts which shouldn't
@@ -858,16 +764,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
858
764
  def proxy= proxy
859
765
  @proxy_uri = case proxy
860
766
  when :ENV then proxy_from_env
861
- when URI::HTTP then proxy
767
+ when Gem::URI::HTTP then proxy
862
768
  when nil then # ignore
863
- else raise ArgumentError, 'proxy must be :ENV or a URI::HTTP'
769
+ else raise ArgumentError, 'proxy must be :ENV or a Gem::URI::HTTP'
864
770
  end
865
771
 
866
772
  @no_proxy.clear
867
773
 
868
774
  if @proxy_uri then
869
775
  @proxy_args = [
870
- @proxy_uri.host,
776
+ @proxy_uri.hostname,
871
777
  @proxy_uri.port,
872
778
  unescape(@proxy_uri.user),
873
779
  unescape(@proxy_uri.password),
@@ -885,13 +791,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
885
791
  end
886
792
 
887
793
  ##
888
- # Creates a URI for an HTTP proxy server from ENV variables.
794
+ # Creates a Gem::URI for an HTTP proxy server from ENV variables.
889
795
  #
890
796
  # If +HTTP_PROXY+ is set a proxy will be returned.
891
797
  #
892
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the URI is given the
798
+ # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Gem::URI is given the
893
799
  # indicated user and password unless HTTP_PROXY contains either of these in
894
- # the URI.
800
+ # the Gem::URI.
895
801
  #
896
802
  # The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
897
803
  # be reached via proxy; if set it should be a comma separated list of
@@ -907,7 +813,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
907
813
 
908
814
  return nil if env_proxy.nil? or env_proxy.empty?
909
815
 
910
- uri = URI normalize_uri env_proxy
816
+ uri = Gem::URI normalize_uri env_proxy
911
817
 
912
818
  env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
913
819
 
@@ -942,133 +848,90 @@ class Bundler::Persistent::Net::HTTP::Persistent
942
848
  end
943
849
 
944
850
  ##
945
- # Forces reconnection of HTTP connections.
851
+ # Forces reconnection of all HTTP connections, including TLS/SSL
852
+ # connections.
946
853
 
947
854
  def reconnect
948
855
  @generation += 1
949
856
  end
950
857
 
951
858
  ##
952
- # Forces reconnection of SSL connections.
859
+ # Forces reconnection of only TLS/SSL connections.
953
860
 
954
861
  def reconnect_ssl
955
862
  @ssl_generation += 1
956
863
  end
957
864
 
958
865
  ##
959
- # Finishes then restarts the Net::HTTP +connection+
866
+ # Finishes then restarts the Gem::Net::HTTP +connection+
960
867
 
961
868
  def reset connection
962
- Thread.current[@request_key].delete connection.object_id
963
- Thread.current[@timeout_key].delete connection.object_id
869
+ http = connection.http
964
870
 
965
871
  finish connection
966
872
 
967
- start connection
873
+ start http
968
874
  rescue Errno::ECONNREFUSED
969
- e = Error.new "connection refused: #{connection.address}:#{connection.port}"
875
+ e = Error.new "connection refused: #{http.address}:#{http.port}"
970
876
  e.set_backtrace $@
971
877
  raise e
972
878
  rescue Errno::EHOSTDOWN
973
- e = Error.new "host down: #{connection.address}:#{connection.port}"
879
+ e = Error.new "host down: #{http.address}:#{http.port}"
974
880
  e.set_backtrace $@
975
881
  raise e
976
882
  end
977
883
 
978
884
  ##
979
- # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
885
+ # Makes a request on +uri+. If +req+ is nil a Gem::Net::HTTP::Get is performed
980
886
  # against +uri+.
981
887
  #
982
- # If a block is passed #request behaves like Net::HTTP#request (the body of
888
+ # If a block is passed #request behaves like Gem::Net::HTTP#request (the body of
983
889
  # the response will not have been read).
984
890
  #
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.
891
+ # +req+ must be a Gem::Net::HTTPGenericRequest subclass (see Gem::Net::HTTP for a list).
989
892
 
990
893
  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
894
+ uri = Gem::URI uri
895
+ req = request_setup req || uri
896
+ response = nil
897
+
898
+ connection_for uri do |connection|
899
+ http = connection.http
900
+
901
+ begin
902
+ connection.requests += 1
903
+
904
+ response = http.request req, &block
905
+
906
+ if req.connection_close? or
907
+ (response.http_version <= '1.0' and
908
+ not response.connection_keep_alive?) or
909
+ response.connection_close? then
910
+ finish connection
911
+ end
912
+ rescue Exception # make sure to close the connection when it was interrupted
913
+ finish connection
914
+
915
+ raise
916
+ ensure
917
+ connection.last_use = Time.now
1008
918
  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
919
  end
1041
920
 
1042
- @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
921
+ @http_versions["#{uri.hostname}:#{uri.port}"] ||= response.http_version
1043
922
 
1044
923
  response
1045
924
  end
1046
925
 
1047
926
  ##
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
927
+ # Creates a GET request if +req_or_uri+ is a Gem::URI and adds headers to the
1065
928
  # request.
1066
929
  #
1067
930
  # Returns the request.
1068
931
 
1069
932
  def request_setup req_or_uri # :nodoc:
1070
- req = if URI === req_or_uri then
1071
- Net::HTTP::Get.new req_or_uri.request_uri
933
+ req = if req_or_uri.respond_to? 'request_uri' then
934
+ Gem::Net::HTTP::Get.new req_or_uri.request_uri
1072
935
  else
1073
936
  req_or_uri
1074
937
  end
@@ -1090,45 +953,15 @@ class Bundler::Persistent::Net::HTTP::Persistent
1090
953
  end
1091
954
 
1092
955
  ##
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!
956
+ # Shuts down all connections
1120
957
  #
1121
- # Do not call this method if other threads are still using their
1122
- # connections! Call #shutdown at the appropriate time instead!
958
+ # *NOTE*: Calling shutdown for can be dangerous!
1123
959
  #
1124
- # Use this method only as a last resort!
960
+ # If any thread is still using a connection it may cause an error! Call
961
+ # #shutdown when you are completely done making requests!
1125
962
 
1126
- def shutdown_in_all_threads
1127
- Thread.list.each do |thread|
1128
- shutdown thread
1129
- end
1130
-
1131
- nil
963
+ def shutdown
964
+ @pool.shutdown { |http| http.finish }
1132
965
  end
1133
966
 
1134
967
  ##
@@ -1137,9 +970,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
1137
970
  def ssl connection
1138
971
  connection.use_ssl = true
1139
972
 
973
+ connection.ciphers = @ciphers if @ciphers
974
+ connection.ssl_timeout = @ssl_timeout if @ssl_timeout
1140
975
  connection.ssl_version = @ssl_version if @ssl_version
976
+ connection.min_version = @min_version if @min_version
977
+ connection.max_version = @max_version if @max_version
1141
978
 
1142
- connection.verify_mode = @verify_mode
979
+ connection.verify_depth = @verify_depth
980
+ connection.verify_mode = @verify_mode
981
+ connection.verify_hostname = @verify_hostname if
982
+ @verify_hostname != nil && connection.respond_to?(:verify_hostname=)
1143
983
 
1144
984
  if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
1145
985
  not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
@@ -1168,8 +1008,10 @@ application:
1168
1008
  WARNING
1169
1009
  end
1170
1010
 
1171
- if @ca_file then
1172
- connection.ca_file = @ca_file
1011
+ connection.ca_file = @ca_file if @ca_file
1012
+ connection.ca_path = @ca_path if @ca_path
1013
+
1014
+ if @ca_file or @ca_path then
1173
1015
  connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
1174
1016
  connection.verify_callback = @verify_callback if @verify_callback
1175
1017
  end
@@ -1189,11 +1031,12 @@ application:
1189
1031
  end
1190
1032
 
1191
1033
  ##
1192
- # Finishes all connections that existed before the given SSL parameter
1193
- # +generation+.
1034
+ # SSL session lifetime
1035
+
1036
+ def ssl_timeout= ssl_timeout
1037
+ @ssl_timeout = ssl_timeout
1194
1038
 
1195
- def ssl_cleanup generation # :nodoc:
1196
- cleanup generation, Thread.current, @ssl_generation_key
1039
+ reconnect_ssl
1197
1040
  end
1198
1041
 
1199
1042
  ##
@@ -1203,7 +1046,34 @@ application:
1203
1046
  @ssl_version = ssl_version
1204
1047
 
1205
1048
  reconnect_ssl
1206
- end if RUBY_VERSION > '1.9'
1049
+ end
1050
+
1051
+ ##
1052
+ # Minimum SSL version to use
1053
+
1054
+ def min_version= min_version
1055
+ @min_version = min_version
1056
+
1057
+ reconnect_ssl
1058
+ end
1059
+
1060
+ ##
1061
+ # maximum SSL version to use
1062
+
1063
+ def max_version= max_version
1064
+ @max_version = max_version
1065
+
1066
+ reconnect_ssl
1067
+ end
1068
+
1069
+ ##
1070
+ # Sets the depth of SSL certificate verification
1071
+
1072
+ def verify_depth= verify_depth
1073
+ @verify_depth = verify_depth
1074
+
1075
+ reconnect_ssl
1076
+ end
1207
1077
 
1208
1078
  ##
1209
1079
  # Sets the HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER.
@@ -1218,6 +1088,15 @@ application:
1218
1088
  reconnect_ssl
1219
1089
  end
1220
1090
 
1091
+ ##
1092
+ # Sets the HTTPS verify_hostname.
1093
+
1094
+ def verify_hostname= verify_hostname
1095
+ @verify_hostname = verify_hostname
1096
+
1097
+ reconnect_ssl
1098
+ end
1099
+
1221
1100
  ##
1222
1101
  # SSL verification callback.
1223
1102
 
@@ -1226,8 +1105,7 @@ application:
1226
1105
 
1227
1106
  reconnect_ssl
1228
1107
  end
1229
-
1230
1108
  end
1231
1109
 
1232
- require 'bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse'
1233
-
1110
+ require_relative 'persistent/connection'
1111
+ require_relative 'persistent/pool'