diff --git a/lib/oauth/request_proxy/action_controller_request.rb b/lib/oauth/request_proxy/action_controller_request.rb index 425deb8c..065279ee 100644 --- a/lib/oauth/request_proxy/action_controller_request.rb +++ b/lib/oauth/request_proxy/action_controller_request.rb @@ -60,7 +60,7 @@ def parameters_for_signature params << header_params.to_query params << request.query_string unless query_string_blank? - if request.post? && request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded") + if raw_post_signature? params << request.raw_post end end @@ -72,6 +72,10 @@ def parameters_for_signature reject { |kv| kv[0] == 'oauth_signature'} end + def raw_post_signature? + (request.post? || request.put?) && request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded") + end + protected def query_params diff --git a/test/units/test_action_controller_request_proxy.rb b/test/units/test_action_controller_request_proxy.rb index a264a1b1..150ce78d 100644 --- a/test/units/test_action_controller_request_proxy.rb +++ b/test/units/test_action_controller_request_proxy.rb @@ -77,7 +77,7 @@ def test_that_proxy_simple_post_request_works_with_post_params def test_that_proxy_simple_put_request_works_with_post_params request_proxy = request_proxy(:put, {}, {'key'=>'value'}) - expected_parameters = [] + expected_parameters = [["key", "value"]] assert_equal expected_parameters, request_proxy.parameters_for_signature assert_equal 'PUT', request_proxy.method end @@ -109,7 +109,7 @@ def test_that_proxy_simple_post_request_works_with_mixed_params def test_that_proxy_simple_put_request_works_with_mixed_params request_proxy = request_proxy(:put, {'key'=>'value'}, {'key2'=>'value2'}) - expected_parameters = [["key", "value"]] + expected_parameters = [["key", "value"],["key2", "value2"]] assert_equal expected_parameters, request_proxy.parameters_for_signature assert_equal 'PUT', request_proxy.method end