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

[rackspace|compute] Handle malformed API responses.

When deleting a Cloud Network, the API returns a plain text
response even when the Content-Type is set to
application/json. In the event of a JSON parsing error, this
change sets the request body to an empty hash.
This commit is contained in:
Brad Gignac 2013-01-31 21:50:58 -05:00
parent ee02e55175
commit 31b72b42f2

View file

@ -127,8 +127,13 @@ module Fog
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp error
end
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
begin
response.body = Fog::JSON.decode(response.body)
rescue MultiJson::DecodeError => e
response.body = {}
end
end
response
end