mirror of
https://github.com/github/rails.git
synced 2026-01-30 00:38:00 -05:00
By default application/xml posts are handled by creating a XmlNode object with the same name as the root element of the submitted xml. M$
ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data|
node = REXML::Document.new(post)
{ node.root.name => node.root }
end
XmlSimple and Yaml web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functio$
request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Luetke]
Closes #4081
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3777 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
35 lines
865 B
Ruby
35 lines
865 B
Ruby
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
|