diff options
Diffstat (limited to 'actionpack/lib/action_controller/deprecated_request_methods.rb')
-rw-r--r-- | actionpack/lib/action_controller/deprecated_request_methods.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/deprecated_request_methods.rb b/actionpack/lib/action_controller/deprecated_request_methods.rb new file mode 100644 index 0000000000..0364831873 --- /dev/null +++ b/actionpack/lib/action_controller/deprecated_request_methods.rb @@ -0,0 +1,34 @@ +module ActionController + class AbstractRequest + # Determine whether the body of a HTTP call is URL-encoded (default) + # or matches one of the registered param_parsers. + # + # For backward compatibility, the post format is extracted from the + # X-Post-Data-Format HTTP header if present. + def post_format + case content_type + when 'application/xml' + :xml + when 'application/x-yaml' + :yaml + else + :url_encoded + end + end + + # Is this a POST request formatted as XML or YAML? + def formatted_post? + post? && (post_format == :yaml || post_format == :xml) + end + + # Is this a POST request formatted as XML? + def xml_post? + post? && post_format == :xml + end + + # Is this a POST request formatted as YAML? + def yaml_post? + post? && post_format == :yaml + end + end +end |