diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 19:01:09 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 19:01:09 +0000 |
commit | 60e40647d7e316600cc9e113ff2af9637f9ecec0 (patch) | |
tree | b2ba137eab7bb11336e11fe649519ff0aaa8df3f | |
parent | 09cec7824800bdd29c97356c71b51acf47ef6bcc (diff) | |
download | rails-60e40647d7e316600cc9e113ff2af9637f9ecec0.tar.gz rails-60e40647d7e316600cc9e113ff2af9637f9ecec0.tar.bz2 rails-60e40647d7e316600cc9e113ff2af9637f9ecec0.zip |
Prepare for mime type reordering depending on the branch [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3850 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/mime_type.rb | 8 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index 13b00c5984..54030f75cc 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -3,6 +3,12 @@ module Mime def self.lookup(string) LOOKUP[string] end + + def self.parse(accept_header) + accept_header.split(",").collect! do |mime_type| + Mime::Type.lookup(mime_type.split(";").first.strip) + end + end def initialize(string, symbol = nil, synonyms = []) @symbol, @synonyms = symbol, synonyms @@ -33,7 +39,7 @@ module Mime ALL = Type.new "*/*", :all HTML = Type.new "text/html", :html, %w( application/xhtml+xml ) JS = Type.new "text/javascript", :js, %w( application/javascript application/x-javascript ) - XML = Type.new "application/xml", :xml, %w( text/xml application/x-xml ) + XML = Type.new "application/xml", :xml, %w( application/x-xml ) RSS = Type.new "application/rss+xml", :rss ATOM = Type.new "application/atom+xml", :atom YAML = Type.new "application/x-yaml", :yaml diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index d5879078af..3bfc8f9385 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -70,9 +70,7 @@ 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.split(";").first.strip) - end + Mime::Type.parse(@env['HTTP_ACCEPT']) end end |