Sha256: ca8c956a4e8f3d75ced65cd5dd3dad805ee6764ba2278e570430ee3475d09842

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

module Fog
  class Connection

    def initialize(url, persistent=false, params={})
      unless params.has_key?(:debug_response)
        params[:debug_response] = true
      end
      params[:headers] ||= {}
      params[:headers]['User-Agent'] ||= "fog/#{Fog::VERSION}"
      @excon = Excon.new(url, params)
      @persistent = persistent
    end

    def request(params, &block)
      unless @persistent
        reset
      end
      unless block_given?
        if (parser = params.delete(:parser))
          body = Nokogiri::XML::SAX::PushParser.new(parser)
          params[:response_block] = lambda { |chunk, remaining, total| body << chunk }
        end
      end

      response = @excon.request(params, &block)

      if parser
        body.finish
        response.body = parser.response
      end

      response
    end

    def reset
      @excon.reset
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
gapinc-fog-1.12.1.1 lib/fog/core/connection.rb
gapinc-fog-1.12.1a lib/fog/core/connection.rb
gapinc-fog-1.12.1 lib/fog/core/connection.rb
fog-1.12.1 lib/fog/core/connection.rb