Skip to content
Browse files

Use request.body IO and rewind, if possible

  • Loading branch information...
1 parent 0863924 commit 3957d44fd10c683518562f22d8b73f1b1c3d455d @jeremy jeremy committed Apr 7, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 actionpack/lib/action_dispatch/middleware/params_parser.rb
View
9 actionpack/lib/action_dispatch/middleware/params_parser.rb
@@ -36,11 +36,14 @@ def parse_formatted_parameters(env)
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 @@ def logger
defined?(Rails.logger) ? Rails.logger : Logger.new($stderr)
end
end
-end
+end

0 comments on commit 3957d44

Please sign in to comment.
Something went wrong with that request. Please try again.