diff options
author | Andre Arko <andre@arko.net> | 2014-07-22 17:29:31 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2014-07-22 17:29:31 -0700 |
commit | 862ced99c4fed5e7b0e4a3da44dd8b11191a0d05 (patch) | |
tree | ea5ef9360361ad20f72f060f4ce1311c590c0007 /lib/bundler/fetcher.rb | |
parent | 7fce490d0b1b1ea92c1a94cfac55c88dc678a485 (diff) | |
download | bundler-862ced99c4fed5e7b0e4a3da44dd8b11191a0d05.tar.gz |
fix ivar warning
fixes #3108
Diffstat (limited to 'lib/bundler/fetcher.rb')
-rw-r--r-- | lib/bundler/fetcher.rb | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index e503fa2c0d..dc1d7d6a22 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -107,31 +107,30 @@ module Bundler end def connection - return @connection if @connection - - needs_ssl = @remote_uri.scheme == "https" || - Bundler.settings[:ssl_verify_mode] || - Bundler.settings[:ssl_client_cert] - raise SSLError if needs_ssl && !defined?(OpenSSL) - - @connection = Net::HTTP::Persistent.new 'bundler', :ENV + @connection ||= begin + needs_ssl = @remote_uri.scheme == "https" || + Bundler.settings[:ssl_verify_mode] || + Bundler.settings[:ssl_client_cert] + raise SSLError if needs_ssl && !defined?(OpenSSL) + + con = Net::HTTP::Persistent.new 'bundler', :ENV + + if @remote_uri.scheme == "https" + con.verify_mode = (Bundler.settings[:ssl_verify_mode] || + OpenSSL::SSL::VERIFY_PEER) + con.cert_store = bundler_cert_store + end - if @remote_uri.scheme == "https" - @connection.verify_mode = (Bundler.settings[:ssl_verify_mode] || - OpenSSL::SSL::VERIFY_PEER) - @connection.cert_store = bundler_cert_store - end + if Bundler.settings[:ssl_client_cert] + pem = File.read(Bundler.settings[:ssl_client_cert]) + con.cert = OpenSSL::X509::Certificate.new(pem) + con.key = OpenSSL::PKey::RSA.new(pem) + end - if Bundler.settings[:ssl_client_cert] - pem = File.read(Bundler.settings[:ssl_client_cert]) - @connection.cert = OpenSSL::X509::Certificate.new(pem) - @connection.key = OpenSSL::PKey::RSA.new(pem) + con.read_timeout = @api_timeout + con.override_headers["User-Agent"] = self.class.user_agent + con end - - @connection.read_timeout = @api_timeout - @connection.override_headers["User-Agent"] = self.class.user_agent - - @connection end def uri |