2010-03-26 14:15:27 -04:00
|
|
|
module Fog
|
|
|
|
class Connection
|
2009-07-13 21:22:42 -04:00
|
|
|
|
2010-03-26 14:15:27 -04:00
|
|
|
def initialize(url)
|
|
|
|
@excon = Excon.new(url)
|
|
|
|
end
|
2009-07-14 19:04:39 -04:00
|
|
|
|
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 }
|
2009-07-13 21:22:42 -04:00
|
|
|
end
|
|
|
|
|
2010-03-26 14:15:27 -04:00
|
|
|
response = @excon.request(params)
|
2009-10-31 15:26:49 -04:00
|
|
|
|
2010-03-26 14:15:27 -04:00
|
|
|
if parser
|
|
|
|
body.finish
|
|
|
|
response.body = parser.response
|
2009-07-14 19:04:39 -04:00
|
|
|
end
|
2009-08-07 03:28:53 -04:00
|
|
|
|
2010-03-26 14:15:27 -04:00
|
|
|
response
|
2009-07-13 21:22:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|