bundler 1.17.2 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2095 -1251
  3. data/LICENSE.md +18 -19
  4. data/README.md +10 -11
  5. data/bundler.gemspec +10 -28
  6. data/exe/bundle +22 -3
  7. data/lib/bundler/build_metadata.rb +4 -12
  8. data/lib/bundler/capistrano.rb +4 -4
  9. data/lib/bundler/cli/add.rb +28 -16
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +24 -17
  12. data/lib/bundler/cli/check.rb +4 -2
  13. data/lib/bundler/cli/clean.rb +1 -1
  14. data/lib/bundler/cli/common.rb +39 -13
  15. data/lib/bundler/cli/config.rb +161 -86
  16. data/lib/bundler/cli/console.rb +1 -1
  17. data/lib/bundler/cli/doctor.rb +20 -9
  18. data/lib/bundler/cli/exec.rb +8 -25
  19. data/lib/bundler/cli/fund.rb +36 -0
  20. data/lib/bundler/cli/gem.rb +213 -32
  21. data/lib/bundler/cli/info.rb +42 -7
  22. data/lib/bundler/cli/init.rb +2 -2
  23. data/lib/bundler/cli/inject.rb +1 -1
  24. data/lib/bundler/cli/install.rb +34 -44
  25. data/lib/bundler/cli/issue.rb +8 -7
  26. data/lib/bundler/cli/list.rb +19 -11
  27. data/lib/bundler/cli/lock.rb +5 -1
  28. data/lib/bundler/cli/open.rb +11 -8
  29. data/lib/bundler/cli/outdated.rb +142 -118
  30. data/lib/bundler/cli/plugin.rb +19 -2
  31. data/lib/bundler/cli/pristine.rb +6 -1
  32. data/lib/bundler/cli/remove.rb +1 -2
  33. data/lib/bundler/cli/show.rb +2 -2
  34. data/lib/bundler/cli/update.rb +43 -16
  35. data/lib/bundler/cli.rb +211 -150
  36. data/lib/bundler/compact_index_client/cache.rb +6 -14
  37. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  38. data/lib/bundler/compact_index_client/updater.rb +15 -28
  39. data/lib/bundler/compact_index_client.rb +28 -12
  40. data/lib/bundler/current_ruby.rb +14 -11
  41. data/lib/bundler/definition.rb +207 -368
  42. data/lib/bundler/dep_proxy.rb +16 -9
  43. data/lib/bundler/dependency.rb +19 -14
  44. data/lib/bundler/deployment.rb +1 -1
  45. data/lib/bundler/digest.rb +71 -0
  46. data/lib/bundler/dsl.rb +81 -81
  47. data/lib/bundler/endpoint_specification.rb +1 -1
  48. data/lib/bundler/env.rb +9 -14
  49. data/lib/bundler/environment_preserver.rb +29 -3
  50. data/lib/bundler/errors.rb +20 -3
  51. data/lib/bundler/feature_flag.rb +14 -33
  52. data/lib/bundler/fetcher/base.rb +1 -1
  53. data/lib/bundler/fetcher/compact_index.rb +28 -14
  54. data/lib/bundler/fetcher/dependency.rb +1 -1
  55. data/lib/bundler/fetcher/downloader.rb +14 -8
  56. data/lib/bundler/fetcher/index.rb +8 -8
  57. data/lib/bundler/fetcher.rb +22 -17
  58. data/lib/bundler/friendly_errors.rb +29 -48
  59. data/lib/bundler/gem_helper.rb +79 -43
  60. data/lib/bundler/gem_helpers.rb +38 -29
  61. data/lib/bundler/gem_tasks.rb +1 -1
  62. data/lib/bundler/gem_version_promoter.rb +5 -5
  63. data/lib/bundler/graph.rb +3 -3
  64. data/lib/bundler/index.rb +9 -9
  65. data/lib/bundler/injector.rb +33 -13
  66. data/lib/bundler/inline.rb +41 -30
  67. data/lib/bundler/installer/gem_installer.rb +9 -18
  68. data/lib/bundler/installer/parallel_installer.rb +50 -33
  69. data/lib/bundler/installer/standalone.rb +30 -11
  70. data/lib/bundler/installer.rb +39 -66
  71. data/lib/bundler/lazy_specification.rb +63 -28
  72. data/lib/bundler/lockfile_generator.rb +1 -1
  73. data/lib/bundler/lockfile_parser.rb +19 -52
  74. data/lib/bundler/{ssl_certs → man}/.document +0 -0
  75. data/{man → lib/bundler/man}/bundle-add.1 +10 -2
  76. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +7 -1
  77. data/{man → lib/bundler/man}/bundle-binstubs.1 +6 -4
  78. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +3 -5
  79. data/lib/bundler/man/bundle-cache.1 +55 -0
  80. data/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +15 -15
  81. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  82. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  83. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  84. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-config.1 +59 -60
  86. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +77 -78
  87. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  88. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-exec.1 +2 -2
  90. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +1 -1
  91. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  92. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  93. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  94. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  95. data/{man → lib/bundler/man}/bundle-init.1 +2 -2
  96. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +1 -1
  97. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  98. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-install.1 +37 -7
  100. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +34 -7
  101. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  102. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  103. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  104. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  106. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  108. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  110. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  112. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  113. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  114. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  115. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  116. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  117. data/{man → lib/bundler/man}/bundle-update.1 +7 -7
  118. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +6 -6
  119. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  120. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  121. data/{man → lib/bundler/man}/bundle.1 +7 -3
  122. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +5 -2
  123. data/{man → lib/bundler/man}/gemfile.5 +44 -21
  124. data/{man → lib/bundler/man}/gemfile.5.ronn +24 -20
  125. data/{man → lib/bundler/man}/index.txt +1 -1
  126. data/lib/bundler/match_platform.rb +1 -1
  127. data/lib/bundler/mirror.rb +5 -5
  128. data/lib/bundler/plugin/api/source.rb +27 -7
  129. data/lib/bundler/plugin/api.rb +1 -1
  130. data/lib/bundler/plugin/dsl.rb +1 -1
  131. data/lib/bundler/plugin/index.rb +27 -4
  132. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  133. data/lib/bundler/plugin/installer.rb +35 -22
  134. data/lib/bundler/plugin/source_list.rb +5 -1
  135. data/lib/bundler/plugin.rb +100 -42
  136. data/lib/bundler/psyched_yaml.rb +0 -15
  137. data/lib/bundler/remote_specification.rb +5 -4
  138. data/lib/bundler/resolver/spec_group.rb +57 -53
  139. data/lib/bundler/resolver.rb +127 -113
  140. data/lib/bundler/retry.rb +4 -4
  141. data/lib/bundler/ruby_version.rb +5 -20
  142. data/lib/bundler/rubygems_ext.rb +103 -79
  143. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  144. data/lib/bundler/rubygems_integration.rb +181 -446
  145. data/lib/bundler/runtime.rb +24 -34
  146. data/lib/bundler/settings.rb +159 -110
  147. data/lib/bundler/setup.rb +11 -12
  148. data/lib/bundler/shared_helpers.rb +56 -90
  149. data/lib/bundler/similarity_detector.rb +3 -3
  150. data/lib/bundler/source/git/git_proxy.rb +106 -105
  151. data/lib/bundler/source/git.rb +66 -39
  152. data/lib/bundler/source/metadata.rb +9 -9
  153. data/lib/bundler/source/path/installer.rb +10 -10
  154. data/lib/bundler/source/path.rb +23 -12
  155. data/lib/bundler/source/rubygems/remote.rb +3 -4
  156. data/lib/bundler/source/rubygems.rb +136 -120
  157. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  158. data/lib/bundler/source.rb +27 -6
  159. data/lib/bundler/source_list.rb +101 -66
  160. data/lib/bundler/source_map.rb +58 -0
  161. data/lib/bundler/spec_set.rb +49 -53
  162. data/lib/bundler/stub_specification.rb +40 -34
  163. data/lib/bundler/templates/Executable.bundler +24 -15
  164. data/lib/bundler/templates/Gemfile +1 -1
  165. data/lib/bundler/templates/gems.rb +1 -1
  166. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  167. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  168. data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
  169. data/lib/bundler/templates/newgem/README.md.tt +7 -5
  170. data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
  171. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  172. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  173. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  174. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  175. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  176. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  177. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  178. data/lib/bundler/templates/newgem/newgem.gemspec.tt +29 -40
  179. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  180. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  181. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  182. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  183. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  184. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  185. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  186. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  187. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  188. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  189. data/lib/bundler/ui/rg_proxy.rb +1 -1
  190. data/lib/bundler/ui/shell.rb +7 -11
  191. data/lib/bundler/ui.rb +3 -3
  192. data/lib/bundler/uri_credentials_filter.rb +10 -4
  193. data/lib/bundler/vendor/.document +1 -0
  194. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  195. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  196. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  197. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  198. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +126 -0
  199. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  200. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
  201. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  202. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  203. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  204. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  205. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  206. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  207. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  208. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  209. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -3
  210. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +39 -11
  211. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +38 -6
  212. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +4 -4
  213. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  214. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  215. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +53 -51
  216. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  217. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -6
  218. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  219. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  220. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  221. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  222. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
  223. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  224. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  225. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  226. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  227. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +20 -9
  228. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  229. data/lib/bundler/vendor/thor/lib/thor/actions.rb +28 -13
  230. data/lib/bundler/vendor/thor/lib/thor/base.rb +63 -43
  231. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  232. data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
  233. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  234. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  235. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  236. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  237. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  238. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  239. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
  240. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  241. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +21 -5
  242. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  243. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  244. data/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  245. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +65 -8
  246. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
  247. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  248. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  249. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  250. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  251. data/lib/bundler/vendor/thor/lib/thor.rb +16 -9
  252. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  253. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  254. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  255. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  256. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  257. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  258. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  259. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  260. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  261. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  262. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  263. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  264. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  265. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  266. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  267. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  268. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  269. data/lib/bundler/vendored_fileutils.rb +1 -6
  270. data/lib/bundler/vendored_molinillo.rb +1 -1
  271. data/lib/bundler/vendored_persistent.rb +7 -12
  272. data/lib/bundler/vendored_thor.rb +2 -2
  273. data/lib/bundler/vendored_tmpdir.rb +4 -0
  274. data/lib/bundler/vendored_tsort.rb +4 -0
  275. data/lib/bundler/vendored_uri.rb +4 -0
  276. data/lib/bundler/version.rb +1 -20
  277. data/lib/bundler/version_ranges.rb +51 -5
  278. data/lib/bundler/vlad.rb +2 -2
  279. data/lib/bundler/worker.rb +21 -8
  280. data/lib/bundler/yaml_serializer.rb +3 -4
  281. data/lib/bundler.rb +248 -118
  282. metadata +115 -190
  283. data/exe/bundle_ruby +0 -60
  284. data/lib/bundler/cli/package.rb +0 -49
  285. data/lib/bundler/compatibility_guard.rb +0 -14
  286. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  287. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  288. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  289. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  290. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  291. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  292. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  293. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  294. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  295. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  296. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  297. data/man/bundle-add.1.txt +0 -52
  298. data/man/bundle-binstubs.1.txt +0 -48
  299. data/man/bundle-check.1.txt +0 -33
  300. data/man/bundle-clean.1.txt +0 -26
  301. data/man/bundle-config.1.txt +0 -529
  302. data/man/bundle-doctor.1.txt +0 -44
  303. data/man/bundle-exec.1.txt +0 -178
  304. data/man/bundle-gem.1.txt +0 -91
  305. data/man/bundle-info.1.txt +0 -21
  306. data/man/bundle-init.1.txt +0 -34
  307. data/man/bundle-inject.1.txt +0 -32
  308. data/man/bundle-install.1.txt +0 -396
  309. data/man/bundle-list.1.txt +0 -43
  310. data/man/bundle-lock.1.txt +0 -93
  311. data/man/bundle-open.1.txt +0 -29
  312. data/man/bundle-outdated.1.txt +0 -131
  313. data/man/bundle-package.1 +0 -55
  314. data/man/bundle-package.1.txt +0 -79
  315. data/man/bundle-platform.1.txt +0 -57
  316. data/man/bundle-pristine.1.txt +0 -44
  317. data/man/bundle-remove.1.txt +0 -34
  318. data/man/bundle-show.1.txt +0 -27
  319. data/man/bundle-update.1.txt +0 -391
  320. data/man/bundle-viz.1.txt +0 -39
  321. data/man/bundle.1.txt +0 -113
  322. data/man/gemfile.5.txt +0 -653
@@ -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.0'
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