diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-14 08:36:19 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-14 08:36:19 +0000 |
commit | db11abbfba2401790f15db98678cee6d3da118a0 (patch) | |
tree | d5b251be52dde5d1df4c1582852fdf39c7e3a019 /actionpack/lib/action_controller/cgi_ext | |
parent | 51f9c931ea47034bcedd5196a783262a4530386d (diff) | |
download | rails-db11abbfba2401790f15db98678cee6d3da118a0.tar.gz rails-db11abbfba2401790f15db98678cee6d3da118a0.tar.bz2 rails-db11abbfba2401790f15db98678cee6d3da118a0.zip |
Added support for POST data in form of YAML or XML, which is controller through the POST_DATA_MARSHAL header
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1303 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/cgi_ext')
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_ext.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_methods.rb | 25 |
2 files changed, 20 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb b/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb index c8ebd57d26..d2973c0c10 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb @@ -25,7 +25,7 @@ class CGI #:nodoc: end def request_parameters - CGIMethods.parse_request_parameters(params) + CGIMethods.parse_request_parameters(params, env_table) end def redirect(where) diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index 3736353b53..0884d0ab89 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -1,4 +1,5 @@ require 'cgi' +require 'action_controller/vendor/xml_simple' # Static methods for parsing the query and request parameters that can be used in # a CGI extension class or testing in isolation. @@ -16,13 +17,13 @@ class CGIMethods #:nodoc: v = CGI.unescape(v) unless v.nil? if k =~ /(.*)\[\]$/ - if parsed_params.has_key? $1 - parsed_params[$1] << v - else - parsed_params[$1] = [v] - end + if parsed_params.has_key? $1 + parsed_params[$1] << v + else + parsed_params[$1] = [v] + end else - parsed_params[k] = v.nil? ? nil : v + parsed_params[k] = v.nil? ? nil : v end } @@ -47,6 +48,18 @@ class CGIMethods #:nodoc: return parsed_params end + def self.parse_formatted_request_parameters(format, raw_post_data) + case format + when :xml + return XmlSimple.xml_in(raw_post_data, 'ForceArray' => false) + when :yaml + return YAML.load(raw_post_data) + end + rescue Object => e + { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace, + "raw_post_data" => raw_post_data, "format" => format } + end + private def CGIMethods.get_typed_value(value) if value.respond_to?(:content_type) && !value.content_type.empty? |