mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
49 lines
723 B
Ruby
49 lines
723 B
Ruby
require 'rubygems'
|
|
require 'excon'
|
|
|
|
require "fog/errors"
|
|
require "fog/response"
|
|
|
|
unless Fog.mocking?
|
|
|
|
module Fog
|
|
class Connection
|
|
|
|
def initialize(url)
|
|
@excon = Excon.new(url)
|
|
end
|
|
|
|
def request(params)
|
|
if parser = params.delete(:parser)
|
|
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
|
params[:block] = lambda { |chunk| body << chunk }
|
|
end
|
|
|
|
response = @excon.request(params)
|
|
|
|
if parser
|
|
body.finish
|
|
response.body = parser.response
|
|
end
|
|
|
|
response
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
else
|
|
|
|
module Fog
|
|
class Connection
|
|
|
|
def initialize(url)
|
|
end
|
|
|
|
def request(params)
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
end
|