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:
parent
ee02e55175
commit
31b72b42f2
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue