[bbg|slicehost] cleanup/consistency update request

This commit is contained in:
geemus 2010-06-01 21:45:07 -07:00
parent 869113a75f
commit f672badddc
2 changed files with 6 additions and 22 deletions

View File

@ -63,8 +63,8 @@ module Fog
def request(params) def request(params)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
headers = { headers = {
'Authorization' => "Basic #{Base64.encode64(@bluebox_api_key).delete("\r\n")}" 'Authorization' => "Basic #{Base64.encode64(@bluebox_api_key).chop!}"
} }.merge!(params[:headers] || {})
case params[:method] case params[:method]
when 'DELETE', 'GET', 'HEAD' when 'DELETE', 'GET', 'HEAD'
headers['Accept'] = 'application/xml' headers['Accept'] = 'application/xml'
@ -72,15 +72,7 @@ module Fog
headers['Content-Type'] = 'application/xml' headers['Content-Type'] = 'application/xml'
end end
@connection.request({ @connection.request({:host => @host}.merge!(params))
:body => params[:body],
:expects => params[:expects],
:headers => headers.merge!(params[:headers] || {}),
:host => @host,
:method => params[:method],
:parser => params[:parser],
:path => params[:path]
})
end end
end end

View File

@ -73,8 +73,8 @@ module Fog
def request(params) def request(params)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
headers = { headers = {
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}" 'Authorization' => "Basic #{Base64.encode64(@slicehost_password).chop!}"
} }.merge!(params[:headers] || {})
case params[:method] case params[:method]
when 'DELETE', 'GET', 'HEAD' when 'DELETE', 'GET', 'HEAD'
headers['Accept'] = 'application/xml' headers['Accept'] = 'application/xml'
@ -83,15 +83,7 @@ module Fog
end end
begin begin
response = @connection.request({ response = @connection.request({:host => @host}.merge!(params))
:body => params[:body],
:expects => params[:expects],
:headers => headers.merge!(params[:headers] || {}),
:host => @host,
:method => params[:method],
:parser => params[:parser],
:path => params[:path]
})
rescue Excon::Errors::Error => error rescue Excon::Errors::Error => error
case error case error
when Excon::Errors::NotFound when Excon::Errors::NotFound