aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb8
-rwxr-xr-xactionpack/lib/action_controller/cgi_ext/cgi_methods.rb4
-rw-r--r--actionpack/lib/action_controller/deprecated_request_methods.rb2
-rw-r--r--actionpack/lib/action_controller/mime_type.rb12
-rwxr-xr-xactionpack/lib/action_controller/request.rb4
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js2
6 files changed, 20 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index c6c052ec56..4663828c96 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -271,7 +271,7 @@ module ActionController #:nodoc:
#
# Example of doing your own parser for a custom content type:
#
- # ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data|
+ # ActionController::Base.param_parsers[Mime::Type.lookup('application/atom+xml')] = Proc.new do |data|
# node = REXML::Document.new(post)
# { node.root.name => node.root }
# end
@@ -281,10 +281,10 @@ module ActionController #:nodoc:
# in params[:r][:name] for "David" instead of params[:name]. To get the old behavior, you can
# re-register XmlSimple as application/xml handler and enable application/x-yaml like this:
#
- # ActionController::Base.param_parsers['application/xml'] =
+ # ActionController::Base.param_parsers[Mime::XML] =
# Proc.new { |data| XmlSimple.xml_in(data, 'ForceArray' => false) }
- # ActionController::Base.param_parsers['application/x-yaml'] = :yaml
- @@param_parsers = { 'application/xml' => :xml_simple }
+ # ActionController::Base.param_parsers[Mime::YAML] = :yaml
+ @@param_parsers = { Mime::XML => :xml_simple }
cattr_accessor :param_parsers
# Template root determines the base from which template references will be made. So a call to render("test/template")
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
index e09fc4ac11..c8a00ac3aa 100755
--- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
+++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
@@ -58,8 +58,8 @@ class CGIMethods #:nodoc:
parsed_params
end
- def self.parse_formatted_request_parameters(format, raw_post_data)
- params = case strategy = ActionController::Base.param_parsers[format]
+ def self.parse_formatted_request_parameters(mime_type, raw_post_data)
+ params = case strategy = ActionController::Base.param_parsers[mime_type]
when Proc
strategy.call(raw_post_data)
when :xml_simple
diff --git a/actionpack/lib/action_controller/deprecated_request_methods.rb b/actionpack/lib/action_controller/deprecated_request_methods.rb
index 0364831873..a6cf87e358 100644
--- a/actionpack/lib/action_controller/deprecated_request_methods.rb
+++ b/actionpack/lib/action_controller/deprecated_request_methods.rb
@@ -6,7 +6,7 @@ module ActionController
# For backward compatibility, the post format is extracted from the
# X-Post-Data-Format HTTP header if present.
def post_format
- case content_type
+ case content_type.to_s
when 'application/xml'
:xml
when 'application/x-yaml'
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb
index ad2f5aaac5..6a33fdc19a 100644
--- a/actionpack/lib/action_controller/mime_type.rb
+++ b/actionpack/lib/action_controller/mime_type.rb
@@ -1,12 +1,16 @@
module Mime
- class Type < String
+ class Type
def self.lookup(string)
LOOKUP[string]
end
def initialize(string, symbol = nil, synonyms = [])
@symbol, @synonyms = symbol, synonyms
- super(string)
+ @string = string
+ end
+
+ def to_s
+ @string
end
def to_sym
@@ -20,6 +24,10 @@ module Mime
super
end
end
+
+ def ==(mime_type)
+ (@synonyms + [ self ]).any? { |synonym| synonym.to_s == mime_type.to_s } if mime_type
+ end
end
ALL = Type.new "*/*", :all
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index cbefc2e490..d5879078af 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -70,8 +70,8 @@ module ActionController
@accepts = if @env['HTTP_ACCEPT'].to_s.strip.blank?
[ content_type, Mime::ALL ]
else
- @env['HTTP_ACCEPT'].split(";").collect! do |mime_type|
- Mime::Type.lookup(mime_type.strip)
+ @env['HTTP_ACCEPT'].split(",").collect! do |mime_type|
+ Mime::Type.lookup(mime_type.split(";").first.strip)
end
end
end
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index 5093f40189..a9195b89e6 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -704,7 +704,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest',
'X-Prototype-Version', Prototype.Version,
- 'Accept', 'text/javascript; text/html; text/xml; */*' ];
+ 'Accept', 'text/javascript, text/xml, text/html, */*' ];
if (this.options.method == 'post') {
requestHeaders.push('Content-type',