diff --git a/lib/fog/aliyun/compute.rb b/lib/fog/aliyun/compute.rb index eefae11..37de741 100644 --- a/lib/fog/aliyun/compute.rb +++ b/lib/fog/aliyun/compute.rb @@ -300,13 +300,18 @@ def reload def request(params) begin - response = @connection.request(params.merge(headers: { + headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token - }.merge!(params[:headers] || {}), - path: "#{@path}/#{params[:path]}", - query: params[:query])) + }.merge!(params[:headers] || {}) + + request_params = params.merge( + headers: headers, + path: "#{@path}/#{params[:path]}", + query: params[:query]) + + response = @connection.request(request_params) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound @@ -316,7 +321,7 @@ def request(params) end end - response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type') == 'application/json' + response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type').start_with?('application/json') response end @@ -339,7 +344,7 @@ def VPCrequest(params) end end - response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type') == 'application/json' + response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type').start_with?('application/json') response end diff --git a/lib/fog/aliyun/models/compute/servers.rb b/lib/fog/aliyun/models/compute/servers.rb index 1767792..4864ece 100644 --- a/lib/fog/aliyun/models/compute/servers.rb +++ b/lib/fog/aliyun/models/compute/servers.rb @@ -10,7 +10,7 @@ class Servers < Fog::Collection model Fog::Compute::Aliyun::Server def all(options = {}) - Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance'] + service.list_servers(options).body['Instances']['Instance'] end # Creates a new server and populates ssh keys