1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use request.body IO and rewind, if possible

This commit is contained in:
Jeremy Kemper 2010-04-07 11:42:07 -07:00
parent 086392492c
commit 3957d44fd1

View file

@ -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
end