diff options
author | Brian Lopez <seniorlopez@gmail.com> | 2009-05-17 10:37:30 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-05-17 10:37:52 -0500 |
commit | 53dda29f8b34073a4b135ee224c1d09c1f10de02 (patch) | |
tree | 4046b55b7609e20c6ef4cc8732724b774b997bf8 /actionpack/lib/action_dispatch/middleware/params_parser.rb | |
parent | 344ee681d6a89ea1da71c39e75c29e0cbda44914 (diff) | |
download | rails-53dda29f8b34073a4b135ee224c1d09c1f10de02.tar.gz rails-53dda29f8b34073a4b135ee224c1d09c1f10de02.tar.bz2 rails-53dda29f8b34073a4b135ee224c1d09c1f10de02.zip |
Add support for parsing XML and JSON from an IO as well as a string [#2659 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/params_parser.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/params_parser.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index 58d527a6e7..a42c6598e0 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -32,16 +32,14 @@ module ActionDispatch when Proc strategy.call(request.raw_post) when :xml_simple, :xml_node - body = request.raw_post - body.blank? ? {} : Hash.from_xml(body).with_indifferent_access + request.body.size == 0 ? {} : Hash.from_xml(request.body).with_indifferent_access when :yaml YAML.load(request.raw_post) when :json - body = request.raw_post - if body.blank? + if request.body.size == 0 {} else - data = ActiveSupport::JSON.decode(body) + data = ActiveSupport::JSON.decode(request.body) data = {:_json => data} unless data.is_a?(Hash) data.with_indifferent_access end |