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:
parent
086392492c
commit
3957d44fd1
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue