diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-15 22:10:03 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-15 22:10:03 +0000 |
commit | f73e1c2ec0711782870b7935da84b40596ad3577 (patch) | |
tree | 5f63f0663938316398b10bd82ad41056ef7779ec /actionpack/lib/action_controller | |
parent | 6d3dc90c33861d7fa8f12e74f18f3c71ac064b65 (diff) | |
download | rails-f73e1c2ec0711782870b7935da84b40596ad3577.tar.gz rails-f73e1c2ec0711782870b7935da84b40596ad3577.tar.bz2 rails-f73e1c2ec0711782870b7935da84b40596ad3577.zip |
Move request parameter parsing from CGI to AbstractRequest.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6742 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/cgi_ext/parameters.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 17 |
3 files changed, 18 insertions, 15 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/parameters.rb b/actionpack/lib/action_controller/cgi_ext/parameters.rb index a7f5393272..d84d0e72e8 100644 --- a/actionpack/lib/action_controller/cgi_ext/parameters.rb +++ b/actionpack/lib/action_controller/cgi_ext/parameters.rb @@ -62,20 +62,6 @@ module ActionController parser.result end - def parse_formatted_request_parameters(mime_type, body) - case strategy = ActionController::Base.param_parsers[mime_type] - when Proc - strategy.call(body) - when :xml_simple, :xml_node - body.blank? ? {} : Hash.from_xml(body).with_indifferent_access - when :yaml - YAML.load(body) - end - rescue Exception => e # YAML, XML or Ruby code block errors - { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace, - "body" => body, "format" => mime_type } - end - private def get_typed_value(value) case value diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index ee6e5ca250..13467be8ef 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -76,7 +76,7 @@ module ActionController #:nodoc: def request_parameters @request_parameters ||= if ActionController::Base.param_parsers.has_key?(content_type) - CGI.parse_formatted_request_parameters(content_type, body.read) + self.class.parse_formatted_request_parameters(content_type, body.read) else CGI.parse_request_parameters(@cgi.params) end diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 3ed8c2f08d..6a9b74d426 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -295,5 +295,22 @@ module ActionController def reset_session #:nodoc: end + + + def self.parse_formatted_request_parameters(mime_type, body) + case strategy = ActionController::Base.param_parsers[mime_type] + when Proc + strategy.call(body) + when :xml_simple, :xml_node + body.blank? ? {} : Hash.from_xml(body).with_indifferent_access + when :yaml + YAML.load(body) + else + {} + end + rescue Exception => e # YAML, XML or Ruby code block errors + { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace, + "body" => body, "format" => mime_type } + end end end |