rubygems-update 3.0.6 → 3.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{History.txt → CHANGELOG.md} +1100 -436
- data/CODE_OF_CONDUCT.md +55 -19
- data/CONTRIBUTING.md +37 -10
- data/MAINTAINERS.txt +1 -6
- data/Manifest.txt +104 -64
- data/POLICIES.md +6 -12
- data/README.md +6 -6
- data/Rakefile +121 -111
- data/bin/gem +0 -6
- data/bin/update_rubygems +2 -2
- data/bundler/CHANGELOG.md +1788 -1251
- data/bundler/LICENSE.md +18 -19
- data/bundler/README.md +9 -10
- data/bundler/UPGRADING.md +215 -0
- data/bundler/bundler.gemspec +9 -26
- data/bundler/exe/bundle +22 -3
- data/bundler/lib/bundler.rb +233 -94
- data/bundler/lib/bundler/build_metadata.rb +5 -13
- data/bundler/lib/bundler/capistrano.rb +4 -4
- data/bundler/lib/bundler/cli.rb +221 -148
- data/bundler/lib/bundler/cli/add.rb +28 -16
- data/bundler/lib/bundler/cli/binstubs.rb +6 -2
- data/bundler/lib/bundler/cli/cache.rb +24 -17
- data/bundler/lib/bundler/cli/clean.rb +1 -1
- data/bundler/lib/bundler/cli/common.rb +25 -12
- data/bundler/lib/bundler/cli/config.rb +161 -86
- data/bundler/lib/bundler/cli/console.rb +1 -1
- data/bundler/lib/bundler/cli/doctor.rb +5 -5
- data/bundler/lib/bundler/cli/exec.rb +8 -20
- data/bundler/lib/bundler/cli/fund.rb +36 -0
- data/bundler/lib/bundler/cli/gem.rb +125 -32
- data/bundler/lib/bundler/cli/info.rb +29 -6
- data/bundler/lib/bundler/cli/init.rb +2 -2
- data/bundler/lib/bundler/cli/inject.rb +1 -1
- data/bundler/lib/bundler/cli/install.rb +27 -23
- data/bundler/lib/bundler/cli/issue.rb +5 -5
- data/bundler/lib/bundler/cli/list.rb +12 -10
- data/bundler/lib/bundler/cli/open.rb +10 -6
- data/bundler/lib/bundler/cli/outdated.rb +134 -109
- data/bundler/lib/bundler/cli/plugin.rb +19 -2
- data/bundler/lib/bundler/cli/pristine.rb +6 -1
- data/bundler/lib/bundler/cli/show.rb +2 -2
- data/bundler/lib/bundler/cli/update.rb +34 -12
- data/bundler/lib/bundler/compact_index_client.rb +26 -10
- data/bundler/lib/bundler/compact_index_client/cache.rb +6 -14
- data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
- data/bundler/lib/bundler/compact_index_client/updater.rb +8 -20
- data/bundler/lib/bundler/current_ruby.rb +9 -7
- data/bundler/lib/bundler/definition.rb +133 -132
- data/bundler/lib/bundler/dep_proxy.rb +16 -9
- data/bundler/lib/bundler/dependency.rb +19 -14
- data/bundler/lib/bundler/deployment.rb +1 -1
- data/bundler/lib/bundler/dsl.rb +54 -71
- data/bundler/lib/bundler/endpoint_specification.rb +1 -1
- data/bundler/lib/bundler/env.rb +9 -14
- data/bundler/lib/bundler/environment_preserver.rb +26 -3
- data/bundler/lib/bundler/errors.rb +1 -0
- data/bundler/lib/bundler/feature_flag.rb +19 -34
- data/bundler/lib/bundler/fetcher.rb +19 -16
- data/bundler/lib/bundler/fetcher/base.rb +1 -1
- data/bundler/lib/bundler/fetcher/compact_index.rb +27 -13
- data/bundler/lib/bundler/fetcher/dependency.rb +1 -1
- data/bundler/lib/bundler/fetcher/downloader.rb +6 -3
- data/bundler/lib/bundler/fetcher/index.rb +8 -7
- data/bundler/lib/bundler/friendly_errors.rb +27 -19
- data/bundler/lib/bundler/gem_helper.rb +68 -37
- data/bundler/lib/bundler/gem_helpers.rb +38 -29
- data/bundler/lib/bundler/gem_tasks.rb +1 -1
- data/bundler/lib/bundler/gem_version_promoter.rb +5 -5
- data/bundler/lib/bundler/graph.rb +3 -3
- data/bundler/lib/bundler/index.rb +12 -7
- data/bundler/lib/bundler/injector.rb +32 -12
- data/bundler/lib/bundler/inline.rb +41 -30
- data/bundler/lib/bundler/installer.rb +41 -60
- data/bundler/lib/bundler/installer/gem_installer.rb +8 -4
- data/bundler/lib/bundler/installer/parallel_installer.rb +20 -26
- data/bundler/lib/bundler/installer/standalone.rb +18 -4
- data/bundler/lib/bundler/lazy_specification.rb +41 -27
- data/bundler/lib/bundler/lockfile_generator.rb +1 -1
- data/bundler/lib/bundler/lockfile_parser.rb +16 -33
- data/bundler/lib/bundler/{ssl_certs → man}/.document +0 -0
- data/bundler/lib/bundler/man/bundle-add.1 +66 -0
- data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +7 -1
- data/bundler/lib/bundler/man/bundle-binstubs.1 +42 -0
- data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +3 -5
- data/bundler/lib/bundler/man/bundle-cache.1 +55 -0
- data/bundler/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +15 -15
- data/bundler/lib/bundler/man/bundle-check.1 +31 -0
- data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-clean.1 +24 -0
- data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-config.1 +488 -0
- data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +59 -67
- data/bundler/lib/bundler/man/bundle-doctor.1 +44 -0
- data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-exec.1 +165 -0
- data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +1 -1
- data/bundler/lib/bundler/man/bundle-gem.1 +102 -0
- data/bundler/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +30 -7
- data/bundler/lib/bundler/man/bundle-info.1 +20 -0
- data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-init.1 +25 -0
- data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +1 -1
- data/bundler/lib/bundler/man/bundle-inject.1 +33 -0
- data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-install.1 +338 -0
- data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +34 -7
- data/bundler/lib/bundler/man/bundle-list.1 +50 -0
- data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
- data/bundler/lib/bundler/man/bundle-lock.1 +84 -0
- data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-open.1 +32 -0
- data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-outdated.1 +155 -0
- data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-platform.1 +61 -0
- data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-pristine.1 +34 -0
- data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-remove.1 +31 -0
- data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-show.1 +23 -0
- data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle-update.1 +394 -0
- data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
- data/bundler/lib/bundler/man/bundle-viz.1 +39 -0
- data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
- data/bundler/lib/bundler/man/bundle.1 +136 -0
- data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +2 -2
- data/bundler/lib/bundler/man/gemfile.5 +686 -0
- data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +16 -20
- data/bundler/lib/bundler/man/index.txt +25 -0
- data/bundler/lib/bundler/match_platform.rb +1 -1
- data/bundler/lib/bundler/mirror.rb +5 -5
- data/bundler/lib/bundler/plugin.rb +75 -36
- data/bundler/lib/bundler/plugin/api.rb +1 -1
- data/bundler/lib/bundler/plugin/api/source.rb +12 -7
- data/bundler/lib/bundler/plugin/dsl.rb +1 -1
- data/bundler/lib/bundler/plugin/index.rb +24 -4
- data/bundler/lib/bundler/plugin/installer.rb +33 -22
- data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -1
- data/bundler/lib/bundler/plugin/source_list.rb +5 -1
- data/bundler/lib/bundler/psyched_yaml.rb +0 -15
- data/bundler/lib/bundler/remote_specification.rb +5 -4
- data/bundler/lib/bundler/resolver.rb +191 -87
- data/bundler/lib/bundler/resolver/spec_group.rb +76 -48
- data/bundler/lib/bundler/retry.rb +3 -3
- data/bundler/lib/bundler/ruby_version.rb +5 -20
- data/bundler/lib/bundler/rubygems_ext.rb +76 -72
- data/bundler/lib/bundler/rubygems_gem_installer.rb +47 -13
- data/bundler/lib/bundler/rubygems_integration.rb +159 -444
- data/bundler/lib/bundler/runtime.rb +6 -23
- data/bundler/lib/bundler/settings.rb +67 -93
- data/bundler/lib/bundler/setup.rb +11 -12
- data/bundler/lib/bundler/shared_helpers.rb +54 -80
- data/bundler/lib/bundler/similarity_detector.rb +3 -3
- data/bundler/lib/bundler/source.rb +12 -6
- data/bundler/lib/bundler/source/git.rb +47 -38
- data/bundler/lib/bundler/source/git/git_proxy.rb +101 -102
- data/bundler/lib/bundler/source/metadata.rb +7 -6
- data/bundler/lib/bundler/source/path.rb +20 -11
- data/bundler/lib/bundler/source/path/installer.rb +10 -10
- data/bundler/lib/bundler/source/rubygems.rb +56 -29
- data/bundler/lib/bundler/source/rubygems/remote.rb +3 -4
- data/bundler/lib/bundler/source_list.rb +32 -30
- data/bundler/lib/bundler/spec_set.rb +37 -25
- data/bundler/lib/bundler/stub_specification.rb +40 -34
- data/bundler/lib/bundler/templates/Executable.bundler +23 -14
- data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
- data/bundler/lib/bundler/templates/newgem/Gemfile.tt +16 -2
- data/bundler/lib/bundler/templates/newgem/README.md.tt +7 -5
- data/bundler/lib/bundler/templates/newgem/Rakefile.tt +19 -5
- data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -0
- data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
- data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
- data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
- data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
- data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +18 -31
- data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
- data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
- data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
- data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
- data/bundler/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
- data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
- data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
- data/bundler/lib/bundler/templates/newgem/travis.yml.tt +0 -1
- data/bundler/lib/bundler/ui.rb +3 -3
- data/bundler/lib/bundler/ui/rg_proxy.rb +1 -1
- data/bundler/lib/bundler/ui/shell.rb +7 -11
- data/bundler/lib/bundler/uri_credentials_filter.rb +10 -4
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -6
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -3
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +39 -11
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +4 -4
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +11 -0
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +53 -51
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor.rb +16 -9
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +28 -13
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +20 -9
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
- data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +63 -43
- data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
- data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
- data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +21 -5
- data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +65 -8
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
- data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/bundler/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/bundler/lib/bundler/vendored_fileutils.rb +1 -6
- data/bundler/lib/bundler/vendored_molinillo.rb +1 -1
- data/bundler/lib/bundler/vendored_persistent.rb +7 -12
- data/bundler/lib/bundler/vendored_thor.rb +2 -2
- data/bundler/lib/bundler/vendored_tmpdir.rb +4 -0
- data/bundler/lib/bundler/vendored_uri.rb +4 -0
- data/bundler/lib/bundler/version.rb +1 -20
- data/bundler/lib/bundler/version_ranges.rb +51 -5
- data/bundler/lib/bundler/vlad.rb +2 -2
- data/bundler/lib/bundler/worker.rb +2 -4
- data/bundler/lib/bundler/yaml_serializer.rb +3 -4
- data/lib/rubygems.rb +198 -222
- data/lib/rubygems/available_set.rb +4 -5
- data/lib/rubygems/basic_specification.rb +32 -19
- data/lib/rubygems/bundler_version_finder.rb +19 -9
- data/lib/rubygems/command.rb +73 -21
- data/lib/rubygems/command_manager.rb +5 -12
- data/lib/rubygems/commands/build_command.rb +51 -18
- data/lib/rubygems/commands/cert_command.rb +2 -11
- data/lib/rubygems/commands/check_command.rb +0 -2
- data/lib/rubygems/commands/cleanup_command.rb +17 -13
- data/lib/rubygems/commands/contents_command.rb +7 -9
- data/lib/rubygems/commands/dependency_command.rb +9 -10
- data/lib/rubygems/commands/environment_command.rb +1 -6
- data/lib/rubygems/commands/fetch_command.rb +2 -4
- data/lib/rubygems/commands/generate_index_command.rb +3 -2
- data/lib/rubygems/commands/help_command.rb +4 -4
- data/lib/rubygems/commands/info_command.rb +9 -4
- data/lib/rubygems/commands/install_command.rb +12 -54
- data/lib/rubygems/commands/list_command.rb +8 -7
- data/lib/rubygems/commands/lock_command.rb +3 -5
- data/lib/rubygems/commands/mirror_command.rb +0 -1
- data/lib/rubygems/commands/open_command.rb +1 -4
- data/lib/rubygems/commands/outdated_command.rb +0 -1
- data/lib/rubygems/commands/owner_command.rb +10 -10
- data/lib/rubygems/commands/pristine_command.rb +13 -9
- data/lib/rubygems/commands/push_command.rb +12 -51
- data/lib/rubygems/commands/query_command.rb +14 -330
- data/lib/rubygems/commands/rdoc_command.rb +0 -1
- data/lib/rubygems/commands/search_command.rb +7 -7
- data/lib/rubygems/commands/server_command.rb +3 -1
- data/lib/rubygems/commands/setup_command.rb +143 -101
- data/lib/rubygems/commands/signin_command.rb +0 -1
- data/lib/rubygems/commands/signout_command.rb +0 -2
- data/lib/rubygems/commands/sources_command.rb +22 -6
- data/lib/rubygems/commands/specification_command.rb +8 -3
- data/lib/rubygems/commands/stale_command.rb +1 -1
- data/lib/rubygems/commands/uninstall_command.rb +2 -3
- data/lib/rubygems/commands/unpack_command.rb +3 -32
- data/lib/rubygems/commands/update_command.rb +73 -28
- data/lib/rubygems/commands/which_command.rb +0 -1
- data/lib/rubygems/commands/yank_command.rb +10 -7
- data/lib/rubygems/compatibility.rb +4 -4
- data/lib/rubygems/config_file.rb +48 -27
- data/lib/rubygems/core_ext/kernel_gem.rb +7 -6
- data/lib/rubygems/core_ext/kernel_require.rb +44 -6
- data/lib/rubygems/core_ext/kernel_warn.rb +22 -13
- data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
- data/lib/rubygems/defaults.rb +110 -23
- data/lib/rubygems/dependency.rb +28 -14
- data/lib/rubygems/dependency_installer.rb +11 -166
- data/lib/rubygems/dependency_list.rb +17 -18
- data/lib/rubygems/deprecate.rb +51 -6
- data/lib/rubygems/doctor.rb +4 -4
- data/lib/rubygems/errors.rb +5 -7
- data/lib/rubygems/exceptions.rb +2 -24
- data/lib/rubygems/ext.rb +6 -6
- data/lib/rubygems/ext/build_error.rb +2 -0
- data/lib/rubygems/ext/builder.rb +45 -82
- data/lib/rubygems/ext/cmake_builder.rb +6 -7
- data/lib/rubygems/ext/configure_builder.rb +5 -8
- data/lib/rubygems/ext/ext_conf_builder.rb +27 -23
- data/lib/rubygems/ext/rake_builder.rb +4 -6
- data/lib/rubygems/gem_runner.rb +3 -10
- data/lib/rubygems/gemcutter_utilities.rb +111 -37
- data/lib/rubygems/indexer.rb +9 -26
- data/lib/rubygems/install_update_options.rb +7 -7
- data/lib/rubygems/installer.rb +91 -98
- data/lib/rubygems/installer_test_case.rb +104 -42
- data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +1 -4
- data/lib/rubygems/name_tuple.rb +4 -7
- data/lib/rubygems/openssl.rb +7 -0
- data/lib/rubygems/package.rb +49 -32
- data/lib/rubygems/package/digest_io.rb +0 -2
- data/lib/rubygems/package/file_source.rb +0 -2
- data/lib/rubygems/package/io_source.rb +0 -2
- data/lib/rubygems/package/old.rb +1 -3
- data/lib/rubygems/package/tar_header.rb +4 -6
- data/lib/rubygems/package/tar_reader.rb +15 -12
- data/lib/rubygems/package/tar_reader/entry.rb +0 -3
- data/lib/rubygems/package/tar_test_case.rb +2 -4
- data/lib/rubygems/package/tar_writer.rb +6 -16
- data/lib/rubygems/package_task.rb +1 -7
- data/lib/rubygems/path_support.rb +2 -2
- data/lib/rubygems/platform.rb +22 -16
- data/lib/rubygems/query_utils.rb +353 -0
- data/lib/rubygems/rdoc.rb +0 -12
- data/lib/rubygems/remote_fetcher.rb +33 -59
- data/lib/rubygems/request.rb +11 -14
- data/lib/rubygems/request/connection_pools.rb +3 -7
- data/lib/rubygems/request/http_pool.rb +0 -1
- data/lib/rubygems/request_set.rb +10 -23
- data/lib/rubygems/request_set/gem_dependency_api.rb +9 -11
- data/lib/rubygems/request_set/lockfile.rb +13 -12
- data/lib/rubygems/request_set/lockfile/parser.rb +2 -2
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +1 -1
- data/lib/rubygems/requirement.rb +36 -35
- data/lib/rubygems/resolver.rb +20 -16
- data/lib/rubygems/resolver/activation_request.rb +27 -51
- data/lib/rubygems/resolver/api_set.rb +31 -24
- data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
- data/lib/rubygems/resolver/api_specification.rb +24 -10
- data/lib/rubygems/resolver/best_set.rb +4 -6
- data/lib/rubygems/resolver/composed_set.rb +3 -5
- data/lib/rubygems/resolver/conflict.rb +2 -9
- data/lib/rubygems/resolver/current_set.rb +0 -2
- data/lib/rubygems/resolver/dependency_request.rb +1 -3
- data/lib/rubygems/resolver/git_set.rb +0 -2
- data/lib/rubygems/resolver/git_specification.rb +0 -2
- data/lib/rubygems/resolver/index_set.rb +1 -3
- data/lib/rubygems/resolver/index_specification.rb +32 -2
- data/lib/rubygems/resolver/installed_specification.rb +0 -2
- data/lib/rubygems/resolver/installer_set.rb +63 -16
- data/lib/rubygems/resolver/local_specification.rb +0 -2
- data/lib/rubygems/resolver/lock_set.rb +3 -5
- data/lib/rubygems/resolver/lock_specification.rb +2 -4
- data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
- data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
- data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +39 -6
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
- data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
- data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +76 -8
- data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +12 -0
- data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
- data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
- data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
- data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
- data/lib/rubygems/resolver/requirement_list.rb +0 -1
- data/lib/rubygems/resolver/set.rb +0 -2
- data/lib/rubygems/resolver/source_set.rb +0 -2
- data/lib/rubygems/resolver/spec_specification.rb +14 -2
- data/lib/rubygems/resolver/specification.rb +13 -2
- data/lib/rubygems/resolver/vendor_set.rb +0 -2
- data/lib/rubygems/resolver/vendor_specification.rb +0 -2
- data/lib/rubygems/s3_uri_signer.rb +15 -13
- data/lib/rubygems/safe_yaml.rb +4 -4
- data/lib/rubygems/security.rb +27 -34
- data/lib/rubygems/security/policy.rb +4 -8
- data/lib/rubygems/security/signer.rb +8 -9
- data/lib/rubygems/security/trust_dir.rb +1 -3
- data/lib/rubygems/server.rb +20 -16
- data/lib/rubygems/source.rb +30 -13
- data/lib/rubygems/source/git.rb +7 -8
- data/lib/rubygems/source/installed.rb +0 -2
- data/lib/rubygems/source/local.rb +2 -4
- data/lib/rubygems/source/lock.rb +0 -2
- data/lib/rubygems/source/specific_file.rb +0 -2
- data/lib/rubygems/source/vendor.rb +0 -2
- data/lib/rubygems/source_list.rb +6 -6
- data/lib/rubygems/spec_fetcher.rb +22 -34
- data/lib/rubygems/specification.rb +207 -278
- data/lib/rubygems/specification_policy.rb +135 -57
- data/{bundler/lib/bundler/ssl_certs/index.rubygems.org → lib/rubygems/ssl_certs/rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
- data/lib/rubygems/stub_specification.rb +4 -5
- data/lib/rubygems/test_case.rb +221 -341
- data/lib/rubygems/test_utilities.rb +22 -18
- data/lib/rubygems/text.rb +2 -3
- data/lib/rubygems/uninstaller.rb +49 -30
- data/lib/rubygems/uri_formatter.rb +2 -4
- data/lib/rubygems/uri_parser.rb +34 -0
- data/lib/rubygems/uri_parsing.rb +23 -0
- data/lib/rubygems/user_interaction.rb +3 -20
- data/lib/rubygems/util.rb +20 -44
- data/lib/rubygems/util/licenses.rb +400 -400
- data/lib/rubygems/validator.rb +9 -31
- data/lib/rubygems/version.rb +29 -21
- data/lib/rubygems/version_option.rb +6 -0
- data/rubygems-update.gemspec +4 -11
- data/setup.rb +2 -7
- data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
- data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
- data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
- data/test/rubygems/rubygems_plugin.rb +0 -2
- data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
- data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +12 -0
- data/test/rubygems/test_bundled_ca.rb +42 -45
- data/test/rubygems/test_config.rb +0 -2
- data/test/rubygems/test_deprecate.rb +41 -5
- data/test/rubygems/test_gem.rb +405 -236
- data/test/rubygems/test_gem_available_set.rb +5 -6
- data/test/rubygems/test_gem_bundler_version_finder.rb +20 -2
- data/test/rubygems/test_gem_command.rb +144 -9
- data/test/rubygems/test_gem_command_manager.rb +40 -17
- data/test/rubygems/test_gem_commands_build_command.rb +386 -13
- data/test/rubygems/test_gem_commands_cert_command.rb +18 -6
- data/test/rubygems/test_gem_commands_check_command.rb +0 -2
- data/test/rubygems/test_gem_commands_cleanup_command.rb +35 -10
- data/test/rubygems/test_gem_commands_contents_command.rb +50 -19
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -3
- data/test/rubygems/test_gem_commands_environment_command.rb +21 -33
- data/test/rubygems/test_gem_commands_fetch_command.rb +0 -2
- data/test/rubygems/test_gem_commands_generate_index_command.rb +32 -2
- data/test/rubygems/test_gem_commands_help_command.rb +16 -8
- data/test/rubygems/test_gem_commands_info_command.rb +6 -7
- data/test/rubygems/test_gem_commands_install_command.rb +368 -34
- data/test/rubygems/test_gem_commands_list_command.rb +0 -2
- data/test/rubygems/test_gem_commands_lock_command.rb +0 -2
- data/test/rubygems/test_gem_commands_mirror.rb +1 -2
- data/test/rubygems/test_gem_commands_open_command.rb +4 -6
- data/test/rubygems/test_gem_commands_outdated_command.rb +18 -1
- data/test/rubygems/test_gem_commands_owner_command.rb +62 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +148 -16
- data/test/rubygems/test_gem_commands_push_command.rb +94 -21
- data/test/rubygems/test_gem_commands_query_command.rb +35 -10
- data/test/rubygems/test_gem_commands_search_command.rb +0 -2
- data/test/rubygems/test_gem_commands_server_command.rb +6 -4
- data/test/rubygems/test_gem_commands_setup_command.rb +228 -128
- data/test/rubygems/test_gem_commands_signin_command.rb +36 -11
- data/test/rubygems/test_gem_commands_signout_command.rb +0 -7
- data/test/rubygems/test_gem_commands_sources_command.rb +193 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +46 -20
- data/test/rubygems/test_gem_commands_stale_command.rb +0 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +108 -52
- data/test/rubygems/test_gem_commands_unpack_command.rb +0 -2
- data/test/rubygems/test_gem_commands_update_command.rb +201 -29
- data/test/rubygems/test_gem_commands_which_command.rb +3 -5
- data/test/rubygems/test_gem_commands_yank_command.rb +86 -5
- data/test/rubygems/test_gem_config_file.rb +25 -13
- data/test/rubygems/test_gem_dependency.rb +6 -2
- data/test/rubygems/test_gem_dependency_installer.rb +169 -252
- data/test/rubygems/test_gem_dependency_list.rb +31 -26
- data/test/rubygems/test_gem_dependency_resolution_error.rb +1 -3
- data/test/rubygems/test_gem_doctor.rb +28 -2
- data/test/rubygems/test_gem_ext_builder.rb +51 -44
- data/test/rubygems/test_gem_ext_cmake_builder.rb +16 -23
- data/test/rubygems/test_gem_ext_configure_builder.rb +6 -14
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -29
- data/test/rubygems/test_gem_ext_rake_builder.rb +39 -22
- data/test/rubygems/test_gem_gem_runner.rb +47 -2
- data/test/rubygems/test_gem_gemcutter_utilities.rb +16 -13
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -2
- data/test/rubygems/test_gem_indexer.rb +40 -55
- data/test/rubygems/test_gem_install_update_options.rb +45 -21
- data/test/rubygems/test_gem_installer.rb +661 -338
- data/test/rubygems/test_gem_local_remote_options.rb +0 -2
- data/test/rubygems/test_gem_name_tuple.rb +0 -2
- data/test/rubygems/test_gem_package.rb +132 -45
- data/test/rubygems/test_gem_package_old.rb +56 -55
- data/test/rubygems/test_gem_package_tar_header.rb +18 -1
- data/test/rubygems/test_gem_package_tar_reader.rb +0 -2
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +6 -7
- data/test/rubygems/test_gem_package_tar_writer.rb +20 -12
- data/test/rubygems/test_gem_package_task.rb +46 -13
- data/test/rubygems/test_gem_path_support.rb +17 -13
- data/test/rubygems/test_gem_platform.rb +74 -7
- data/test/rubygems/test_gem_rdoc.rb +0 -1
- data/test/rubygems/test_gem_remote_fetcher.rb +223 -209
- data/test/rubygems/test_gem_request.rb +30 -19
- data/test/rubygems/test_gem_request_connection_pools.rb +2 -2
- data/test/rubygems/test_gem_request_set.rb +104 -29
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +4 -6
- data/test/rubygems/test_gem_request_set_lockfile.rb +4 -5
- data/test/rubygems/test_gem_request_set_lockfile_parser.rb +9 -10
- data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +118 -118
- data/test/rubygems/test_gem_requirement.rb +50 -4
- data/test/rubygems/test_gem_resolver.rb +73 -31
- data/test/rubygems/test_gem_resolver_activation_request.rb +3 -34
- data/test/rubygems/test_gem_resolver_api_set.rb +60 -59
- data/test/rubygems/test_gem_resolver_api_specification.rb +3 -5
- data/test/rubygems/test_gem_resolver_best_set.rb +27 -6
- data/test/rubygems/test_gem_resolver_composed_set.rb +0 -2
- data/test/rubygems/test_gem_resolver_conflict.rb +1 -7
- data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -2
- data/test/rubygems/test_gem_resolver_git_set.rb +0 -2
- data/test/rubygems/test_gem_resolver_git_specification.rb +1 -2
- data/test/rubygems/test_gem_resolver_index_set.rb +2 -4
- data/test/rubygems/test_gem_resolver_index_specification.rb +7 -4
- data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -3
- data/test/rubygems/test_gem_resolver_installer_set.rb +10 -10
- data/test/rubygems/test_gem_resolver_local_specification.rb +0 -2
- data/test/rubygems/test_gem_resolver_lock_set.rb +3 -5
- data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -2
- data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -2
- data/test/rubygems/test_gem_resolver_specification.rb +0 -2
- data/test/rubygems/test_gem_resolver_vendor_set.rb +1 -3
- data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -2
- data/test/rubygems/test_gem_security.rb +27 -25
- data/test/rubygems/test_gem_security_policy.rb +7 -12
- data/test/rubygems/test_gem_security_signer.rb +11 -12
- data/test/rubygems/test_gem_security_trust_dir.rb +4 -6
- data/test/rubygems/test_gem_server.rb +13 -12
- data/test/rubygems/test_gem_silent_ui.rb +0 -1
- data/test/rubygems/test_gem_source.rb +32 -17
- data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
- data/test/rubygems/test_gem_source_git.rb +12 -18
- data/test/rubygems/test_gem_source_installed.rb +11 -13
- data/test/rubygems/test_gem_source_list.rb +1 -1
- data/test/rubygems/test_gem_source_local.rb +8 -9
- data/test/rubygems/test_gem_source_lock.rb +17 -19
- data/test/rubygems/test_gem_source_specific_file.rb +9 -10
- data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
- data/test/rubygems/test_gem_source_vendor.rb +7 -9
- data/test/rubygems/test_gem_spec_fetcher.rb +11 -4
- data/test/rubygems/test_gem_specification.rb +363 -245
- data/test/rubygems/test_gem_stream_ui.rb +3 -1
- data/test/rubygems/test_gem_stub_specification.rb +6 -7
- data/test/rubygems/test_gem_text.rb +1 -2
- data/test/rubygems/test_gem_uninstaller.rb +165 -22
- data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -2
- data/test/rubygems/test_gem_uri_formatter.rb +0 -2
- data/test/rubygems/test_gem_util.rb +17 -15
- data/test/rubygems/test_gem_validator.rb +4 -7
- data/test/rubygems/test_gem_version.rb +23 -10
- data/test/rubygems/test_gem_version_option.rb +1 -3
- data/test/rubygems/test_kernel.rb +25 -9
- data/test/rubygems/test_project_sanity.rb +20 -0
- data/test/rubygems/test_remote_fetch_error.rb +1 -2
- data/test/rubygems/test_require.rb +394 -56
- data/test/test_changelog_generator.rb +17 -0
- metadata +109 -155
- data/.rubocop.yml +0 -67
- data/.travis.yml +0 -38
- data/appveyor.yml +0 -43
- data/bundler/CODE_OF_CONDUCT.md +0 -42
- data/bundler/CONTRIBUTING.md +0 -17
- data/bundler/exe/bundle_ruby +0 -60
- data/bundler/lib/bundler/cli/package.rb +0 -49
- data/bundler/lib/bundler/compatibility_guard.rb +0 -14
- data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
- data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
- data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
- data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
- data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
- data/lib/rubygems/source_local.rb +0 -7
- data/lib/rubygems/source_specific_file.rb +0 -6
- data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
- data/lib/ubygems.rb +0 -14
- data/util/CL2notes +0 -55
- data/util/ci +0 -82
- data/util/cops/deprecations.rb +0 -52
- data/util/create_certs.rb +0 -171
- data/util/create_certs.sh +0 -27
- data/util/create_encrypted_key.rb +0 -16
- data/util/generate_spdx_license_list.rb +0 -61
- data/util/patch_with_prs.rb +0 -77
- data/util/rubocop +0 -8
- data/util/update_bundled_ca_certificates.rb +0 -139
- data/util/update_changelog.rb +0 -67
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'dependency_graph'
|
4
4
|
|
5
5
|
module Bundler::Molinillo
|
6
6
|
# This class encapsulates a dependency resolver.
|
@@ -9,7 +9,7 @@ module Bundler::Molinillo
|
|
9
9
|
#
|
10
10
|
#
|
11
11
|
class Resolver
|
12
|
-
|
12
|
+
require_relative 'resolution'
|
13
13
|
|
14
14
|
# @return [SpecificationProvider] the specification provider used
|
15
15
|
# in the resolution process
|
@@ -1,17 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
|
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
|
-
#
|
26
|
-
# connections.
|
15
|
+
# Connections will be shared across threads through a connection pool to
|
16
|
+
# increase reuse of connections.
|
27
17
|
#
|
28
|
-
#
|
29
|
-
#
|
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
|
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
|
-
#
|
66
|
-
# URI.
|
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
|
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-
|
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
|
-
#
|
106
|
-
#
|
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
|
111
|
-
# reset upon the next use to avoid attempting to send to a
|
112
|
-
# The default value is 5 seconds. nil means no 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
|
128
|
-
# effect, if set, connections will be reset on the request after
|
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
|
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
|
-
|
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
|
-
#
|
210
|
-
# the exception list for ruby 1.x.
|
175
|
+
# The version of Bundler::Persistent::Net::HTTP::Persistent you are using
|
211
176
|
|
212
|
-
|
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
|
-
|
207
|
+
http.connection_for uri do |connection|
|
208
|
+
sleep_time = 0
|
252
209
|
|
253
|
-
|
210
|
+
http = connection.http
|
254
211
|
|
255
|
-
|
256
|
-
|
212
|
+
loop do
|
213
|
+
response = http.request req
|
257
214
|
|
258
|
-
|
215
|
+
$stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
|
259
216
|
|
260
|
-
|
261
|
-
|
262
|
-
|
217
|
+
unless Net::HTTPOK === response then
|
218
|
+
raise Error, "bad response code #{response.code} detecting idle timeout"
|
219
|
+
end
|
263
220
|
|
264
|
-
|
221
|
+
break if sleep_time >= max
|
265
222
|
|
266
|
-
|
223
|
+
sleep_time += 1
|
267
224
|
|
268
|
-
|
269
|
-
|
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
|
-
#
|
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
|
-
#
|
368
|
+
# Seconds to wait until writing one block. See Net::HTTP#write_timeout
|
392
369
|
|
393
|
-
|
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
|
-
#
|
398
|
+
# SSL session lifetime
|
422
399
|
|
423
|
-
attr_reader :
|
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
|
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
|
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+
|
469
|
-
#
|
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
|
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
|
-
|
502
|
-
|
503
|
-
|
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
|
-
#
|
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
|
569
|
-
|
570
|
-
timeouts = thread[@timeout_key]
|
566
|
+
def ciphers= ciphers
|
567
|
+
@ciphers = ciphers
|
571
568
|
|
572
|
-
|
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
|
-
|
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 =
|
588
|
+
connection = @pool.checkout net_http_args
|
624
589
|
|
625
|
-
|
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
|
-
|
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
|
-
|
636
|
-
|
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 =
|
641
|
-
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 =
|
646
|
-
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
|
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
|
699
|
-
|
700
|
-
|
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
|
-
|
657
|
+
http.start
|
703
658
|
|
704
|
-
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
|
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
|
-
|
726
|
-
|
727
|
-
|
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.
|
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
|
-
#
|
817
|
-
# block is given. Returns all responses received.
|
694
|
+
# Set the maximum number of retries for a request.
|
818
695
|
#
|
819
|
-
#
|
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
|
-
#
|
824
|
-
|
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
|
-
|
827
|
-
connection = connection_for uri
|
705
|
+
@max_retries = retries
|
828
706
|
|
829
|
-
|
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.
|
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
|
-
|
963
|
-
Thread.current[@timeout_key].delete connection.object_id
|
841
|
+
http = connection.http
|
964
842
|
|
965
843
|
finish connection
|
966
844
|
|
967
|
-
start
|
845
|
+
start http
|
968
846
|
rescue Errno::ECONNREFUSED
|
969
|
-
e = Error.new "connection refused: #{
|
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: #{
|
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::
|
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
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
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.
|
893
|
+
@http_versions["#{uri.hostname}:#{uri.port}"] ||= response.http_version
|
1043
894
|
|
1044
895
|
response
|
1045
896
|
end
|
1046
897
|
|
1047
898
|
##
|
1048
|
-
#
|
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
|
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
|
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
|
-
#
|
1122
|
-
# connections! Call #shutdown at the appropriate time instead!
|
930
|
+
# *NOTE*: Calling shutdown for can be dangerous!
|
1123
931
|
#
|
1124
|
-
#
|
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
|
1127
|
-
|
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.
|
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
|
1172
|
-
|
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
|
-
#
|
1193
|
-
|
1004
|
+
# SSL session lifetime
|
1005
|
+
|
1006
|
+
def ssl_timeout= ssl_timeout
|
1007
|
+
@ssl_timeout = ssl_timeout
|
1194
1008
|
|
1195
|
-
|
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
|
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
|
-
|
1071
|
+
require_relative 'persistent/connection'
|
1072
|
+
require_relative 'persistent/pool'
|
1233
1073
|
|