fog--fog/lib/fog/connection.rb

36 lines
641 B
Ruby
Raw Normal View History

2010-03-26 18:15:27 +00:00
module Fog
class Connection
def initialize(url, persistent=false)
2010-03-26 18:15:27 +00:00
@excon = Excon.new(url)
@persistent = persistent
2010-03-26 18:15:27 +00:00
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| body << chunk }
end
end
response = @excon.request(params, &block)
2010-03-26 18:15:27 +00:00
if parser
body.finish
response.body = parser.response
end
2009-08-07 07:28:53 +00:00
2010-03-26 18:15:27 +00:00
response
end
def reset
@excon.reset
end
end
end