Object
# File lib/action_dispatch/middleware/params_parser.rb, line 65
65: def content_type_from_legacy_post_data_format_header(env)
66: if x_post_format = env['HTTP_X_POST_DATA_FORMAT']
67: case x_post_format.to_s.downcase
68: when 'yaml' then return Mime::YAML
69: when 'xml' then return Mime::XML
70: end
71: end
72:
73: nil
74: end
# File lib/action_dispatch/middleware/params_parser.rb, line 76
76: def logger
77: defined?(Rails.logger) ? Rails.logger : Logger.new($stderr)
78: end
# File lib/action_dispatch/middleware/params_parser.rb, line 25
25: def parse_formatted_parameters(env)
26: request = Request.new(env)
27:
28: return false if request.content_length.zero?
29:
30: mime_type = content_type_from_legacy_post_data_format_header(env) ||
31: request.content_mime_type
32:
33: strategy = @parsers[mime_type]
34:
35: return false unless strategy
36:
37: case strategy
38: when Proc
39: strategy.call(request.raw_post)
40: when :xml_simple, :xml_node
41: data = Hash.from_xml(request.body.read) || {}
42: request.body.rewind if request.body.respond_to?(:rewind)
43: data.with_indifferent_access
44: when :yaml
45: YAML.load(request.raw_post)
46: when :json
47: data = ActiveSupport::JSON.decode(request.body)
48: request.body.rewind if request.body.respond_to?(:rewind)
49: data = {:_json => data} unless data.is_a?(Hash)
50: data.with_indifferent_access
51: else
52: false
53: end
54: rescue Exception => e # YAML, XML or Ruby code block errors
55: logger.debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}"
56:
57: raise
58: { "body" => request.raw_post,
59: "content_type" => request.content_mime_type,
60: "content_length" => request.content_length,
61: "exception" => "#{e.message} (#{e.class})",
62: "backtrace" => e.backtrace }
63: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.