From 3957d44fd10c683518562f22d8b73f1b1c3d455d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 7 Apr 2010 11:42:07 -0700 Subject: Use request.body IO and rewind, if possible --- actionpack/lib/action_dispatch/middleware/params_parser.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index c0efdae2a0..1524b00d5b 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -36,11 +36,14 @@ module ActionDispatch when Proc strategy.call(request.raw_post) when :xml_simple, :xml_node - (Hash.from_xml(request.raw_post) || {}).with_indifferent_access + data = Hash.from_xml(request.body) || {} + request.body.rewind if request.body.respond_to?(:rewind) + data.with_indifferent_access when :yaml YAML.load(request.raw_post) when :json - data = ActiveSupport::JSON.decode(request.raw_post) + data = ActiveSupport::JSON.decode(request.body) + request.body.rewind if request.body.respond_to?(:rewind) data = {:_json => data} unless data.is_a?(Hash) data.with_indifferent_access else @@ -72,4 +75,4 @@ module ActionDispatch defined?(Rails.logger) ? Rails.logger : Logger.new($stderr) end end -end \ No newline at end of file +end -- cgit v1.2.3