2010-03-26 18:15:27 +00:00
|
|
|
module Fog
|
|
|
|
class Connection
|
2009-07-14 01:22:42 +00:00
|
|
|
|
2010-03-26 18:15:27 +00:00
|
|
|
def initialize(url)
|
|
|
|
@excon = Excon.new(url)
|
|
|
|
end
|
2009-07-14 23:04:39 +00:00
|
|
|
|
2010-05-09 23:23:03 +00:00
|
|
|
def request(params, &block)
|
|
|
|
unless block_given?
|
|
|
|
if (parser = params.delete(:parser))
|
|
|
|
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
|
|
|
block = lambda { |chunk| body << chunk }
|
|
|
|
end
|
2009-07-14 01:22:42 +00:00
|
|
|
end
|
|
|
|
|
2010-05-09 23:23:03 +00:00
|
|
|
response = @excon.request(params, &block)
|
2009-10-31 19:26:49 +00:00
|
|
|
|
2010-03-26 18:15:27 +00:00
|
|
|
if parser
|
|
|
|
body.finish
|
|
|
|
response.body = parser.response
|
2009-07-14 23:04:39 +00:00
|
|
|
end
|
2009-08-07 07:28:53 +00:00
|
|
|
|
2010-03-26 18:15:27 +00:00
|
|
|
response
|
2009-07-14 01:22:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|