1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/connection.rb

26 lines
448 B
Ruby
Raw Normal View History

2010-03-26 14:15:27 -04:00
module Fog
class Connection
2010-03-26 14:15:27 -04:00
def initialize(url)
@excon = Excon.new(url)
end
2010-03-26 14:15:27 -04:00
def request(params)
if parser = params.delete(:parser)
body = Nokogiri::XML::SAX::PushParser.new(parser)
params[:block] = lambda { |chunk| body << chunk }
end
2010-03-26 14:15:27 -04:00
response = @excon.request(params)
2010-03-26 14:15:27 -04:00
if parser
body.finish
response.body = parser.response
end
2009-08-07 03:28:53 -04:00
2010-03-26 14:15:27 -04:00
response
end
end
end