bundler icon indicating copy to clipboard operation
bundler copied to clipboard

Issue without openssl installed

Open epinault opened this issue 11 years ago • 0 comments

Bundler goes to the wrong server if I install ruby without openssl. Currently with Ruby 1.9.3-p392 and 1.9.3-p362, and bundler 1.3.x,

If I do the following

bundle install --path vendor --verbose Fetching from: http://rubygems.org/api/v1/dependencies HTTP Success Fetching source index from http://rubygems.org/ Fetching from: http://rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz HTTP Redirection Fetching from: http://production.cf.rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz HTTP Redirection Fetching from: http://production.cf.rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz HTTP Redirection Fetching from: http://production.cf.rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz HTTP Redirection Fetching from: http://production.cf.rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz

Notice the infinite loop to the 2nd url...

What is wrong is the code when looking at it closely. The way it is coded is roughly equivalent to the following code

require "net/http"

host = "rubygems.org"
port = "80"
connection = Net::HTTP.new(host, port)

request_uri = "/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz"
req = Net::HTTP::Get.new request_uri
puts req.inspect
puts connection.inspect
response = connection.request(req)

puts response.inspect

request_uri = "http://production.cf.rubygems.org/quick/Marshal.4.8/actionmailer-3.2.11.gemspec.rz"
req = Net::HTTP::Get.new request_uri
puts req.inspect
puts connection.inspect
response = connection.request(req)

puts response.inspect

You cannot pass a request object the 2nd time as the host is not being reset correctly. Hence then infinite loop as it talks to the first host with same path over and over...

Checkin the fetch method in lib/bundler/fetcher.rb, and in the else, it needs to propage the host and port from the new URI or reset to a new connection object. See the bold line.. I will try to submit a patch later

def fetch(uri, counter = 0)
      raise HTTPError, "Too many redirects" if counter >= REDIRECT_LIMIT

      begin
        Bundler.ui.debug "Fetching from: #{uri}"
        puts defined?(Net::HTTP::Persistent)

        if defined?(Net::HTTP::Persistent)
          response = @connection.request(uri)
        else
         ***@connection = Net::HTTP.new(uri.host, uri.port)***

          req = Net::HTTP::Get.new uri.request_uri
          @connection.host = uri.host
          response = @connection.request(req)
        end
      rescue OpenSSL::SSL::SSLError

epinault avatar Apr 23 '13 21:04 epinault