mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
ab3e04b7ae
excon was updated to allow for tracking progress, and though we are not using this feature we still need to acknowledge the change in the params that are passed back to blocks for requests. Closes #245 Closes #246
35 lines
678 B
Ruby
35 lines
678 B
Ruby
module Fog
|
|
class Connection
|
|
|
|
def initialize(url, persistent=false, params={})
|
|
@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)
|
|
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
|