# File lib/bundler/fetcher.rb, line 64
    def specs(gem_names, source)
      index = Index.new

      if !gem_names || @remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
        Bundler.ui.info "Fetching source index from #{strip_user_pass_from_uri(@remote_uri)}"
        specs = fetch_all_remote_specs
      else
        Bundler.ui.info "Fetching gem metadata from #{strip_user_pass_from_uri(@remote_uri)}", Bundler.ui.debug?
        begin
          specs = fetch_remote_specs(gem_names)
        # fall back to the legacy index in the following cases
        # 1. Gemcutter Endpoint doesn't return a 200
        # 2. Marshal blob doesn't load properly
        # 3. One of the YAML gemspecs has the Syck::DefaultKey problem
        rescue HTTPError, TypeError, GemspecError => e
          # new line now that the dots are over
          Bundler.ui.info "" unless Bundler.ui.debug?

          if @remote_uri.to_s.include?("rubygems.org")
            Bundler.ui.info "Error #{e.class} during request to dependency API"
          end
          Bundler.ui.debug e.message
          Bundler.ui.debug e.backtrace

          Bundler.ui.info "Fetching full source index from #{strip_user_pass_from_uri(@remote_uri)}"
          specs = fetch_all_remote_specs
        else
          # new line now that the dots are over
          Bundler.ui.info "" unless Bundler.ui.debug?
        end
      end

      specs[@remote_uri].each do |name, version, platform, dependencies|
        next if name == 'bundler'
        spec = nil
        if dependencies
          spec = EndpointSpecification.new(name, version, platform, dependencies)
        else
          spec = RemoteSpecification.new(name, version, platform, self)
        end
        spec.source = source
        @@spec_fetch_map[spec.full_name] = [spec, @remote_uri]
        index << spec
      end

      index
    end