def download(resource)
      client              = get_http_client
      @size               = 0
      @speed              = 0
      @sanitized_resource = sanitize_resource(resource)
      resource            = parse_resource(resource)
      attempts            = 0

      begin
        balancer.request do |endpoint|
          RightSupport::Net::SSL.with_expected_hostname(ips[endpoint]) do
            logger.info("Requesting '#{sanitized_resource}' from '#{endpoint}'")

            attempts += 1
            t0 = Time.now

            # Previously we accessed RestClient directly and used it's wrapper method to instantiate
            # a RestClient::Request object.  This wrapper was not passing all options down the stack
            # so now we invoke the RestClient::Request object directly, passing it our desired options
            client.execute(:method => :get, :url => "https://#{endpoint}:443#{resource}", :timeout => calculate_timeout(attempts),
                           :verify_ssl => OpenSSL::SSL::VERIFY_PEER, :ssl_ca_file => get_ca_file,
                           :ssl_version => RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
                           :headers => {:user_agent => "RightLink v#{AgentConfig.protocol_version}",
                                        'X-RightLink-Version' => RightLink.version }) do |response, request, result|
              if result.kind_of?(Net::HTTPSuccess)
                @size = result.content_length || response.size || 0
                @speed = @size / (Time.now - t0)
                yield response
              else
                response.return!(request, result)
              end
            end
          end
        end
      rescue Exception => e
        list = parse_exception_message(e)
        message = list.join(", ")
        logger.error("Request '#{sanitized_resource}' failed - #{message}")
        raise ConnectionException, message unless (list & CONNECTION_EXCEPTIONS).empty?
        raise DownloadException, message
      end
    end
def download(resource)
      client              = get_http_client
      @size               = 0
      @speed              = 0
      @sanitized_resource = sanitize_resource(resource)
      resource            = parse_resource(resource)
      attempts            = 0

      begin
        balancer.request do |endpoint|
          RightSupport::Net::SSL.with_expected_hostname(ips[endpoint]) do
            logger.info("Requesting '#{sanitized_resource}' from '#{endpoint}'")

            attempts += 1
            t0 = Time.now

            # Previously we accessed RestClient directly and used it's wrapper method to instantiate
            # a RestClient::Request object.  This wrapper was not passing all options down the stack
            # so now we invoke the RestClient::Request object directly, passing it our desired options
            client.execute(:method => :get, :url => "https://#{endpoint}:443#{resource}", :timeout => calculate_timeout(attempts),
                           :verify_ssl => OpenSSL::SSL::VERIFY_PEER, :ssl_ca_file => get_ca_file,
                           :ssl_version => RightSupport::Net::HTTPClient::DEFAULT_OPTIONS[:ssl_version],
                           :headers => {:user_agent => "RightLink v#{AgentConfig.protocol_version}",
                                        'X-RightLink-Version' => RightLink.version }) do |response, request, result|
              if result.kind_of?(Net::HTTPSuccess)
                @size = result.content_length || response.size || 0
                @speed = @size / (Time.now - t0)
                yield response
              else
                response.return!(request, result)
              end
            end
          end
        end
      rescue Exception => e
        list = parse_exception_message(e)
        message = list.join(", ")
        logger.error("Request '#{sanitized_resource}' failed - #{message}")
        raise ConnectionException, message unless (list & CONNECTION_EXCEPTIONS).empty?
        raise DownloadException, message
      end
    end
Initializes a Downloader with a list of hostnames

 The purpose of this method is to instantiate a Downloader.
 It will perform DNS resolution on the hostnames provided
 and will configure a proxy if necessary

 === Parameters
 @param <[String]> Hostnames to resolve

 === Return
 @return [Downloader]

 Downloads an attachment from Repose

 The purpose of this method is to download the specified attachment from Repose
 If a failure is encountered it will provide proper feedback regarding the nature
 of the failure

 === Parameters
 @param [String] Resource URI to parse and fetch

 === Block
 @yield [] A block is mandatory
 @yieldreturn [String] The stream that is being fetched