diff --git a/lib/aliyunsdkcore/roa_client.rb b/lib/aliyunsdkcore/roa_client.rb index 92473f9..d54cb44 100644 --- a/lib/aliyunsdkcore/roa_client.rb +++ b/lib/aliyunsdkcore/roa_client.rb @@ -1,6 +1,5 @@ require 'faraday' require 'securerandom' -require 'active_support/all' module AliyunSDKCore @@ -21,7 +20,9 @@ def initialize(config) def request(method:, uri:, params: {}, body: {}, headers: {}, options: {}) # :"Content-Type" => "application/json" to "content-type" => "application/json" - headers.deep_transform_keys! { |key| key.to_s.downcase } + headers.each_with_object({}) do |(key, value), result| + result[key.to_s.downcase] = value + end mix_headers = default_headers.merge(headers) response = connection.send(method.downcase) do |request| diff --git a/spec/roa_client_spec.rb b/spec/roa_client_spec.rb index 4d4cca5..af6492e 100644 --- a/spec/roa_client_spec.rb +++ b/spec/roa_client_spec.rb @@ -221,7 +221,7 @@ it 'should ok' do stub_request(:get, "https://ros.aliyuncs.com/") .to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json) - response = roa_client.put(uri: '/', body: 'text') + response = roa_client.put(uri: '/', body: 'text', headers: {'Content-Type': 'application/json'}) expect(response.body).to eq('{"ok":true}') end end