method
parse_formatted_request_parameters
v2.2.1 -
Show latest stable
-
0 notes -
Class: ActionController::AbstractRequest
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
parse_formatted_request_parameters()
private
Hide source
# File actionpack/lib/action_controller/request.rb, line 491 def parse_formatted_request_parameters return {} if content_length.zero? content_type, boundary = self.class.extract_multipart_boundary(content_type_with_parameters) # Don't parse params for unknown requests. return {} if content_type.blank? mime_type = Mime::Type.lookup(content_type) strategy = ActionController::Base.param_parsers[mime_type] # Only multipart form parsing expects a stream. body = (strategy && strategy != :multipart_form) ? raw_post : self.body case strategy when Proc strategy.call(body) when :url_encoded_form self.class.clean_up_ajax_request_body! body self.class.parse_query_parameters(body) when :multipart_form self.class.parse_multipart_form_parameters(body, boundary, content_length, env) when :xml_simple, :xml_node body.blank? ? {} : Hash.from_xml(body).with_indifferent_access when :yaml YAML.load(body) when :json if body.blank? {} else data = ActiveSupport::JSON.decode(body) data = {:_json => data} unless data.is_a?(Hash) data.with_indifferent_access end else {} end rescue Exception => e # YAML, XML or Ruby code block errors raise { "body" => body, "content_type" => content_type_with_parameters, "content_length" => content_length, "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace } end