diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 18:50:14 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-12 18:50:14 +0000 |
commit | 09cec7824800bdd29c97356c71b51acf47ef6bcc (patch) | |
tree | 40fc15739537e9114f592ef7f7bed8e44071c43d | |
parent | e3ea34f7d30b9866da8f34be4108f8449218f9fd (diff) | |
download | rails-09cec7824800bdd29c97356c71b51acf47ef6bcc.tar.gz rails-09cec7824800bdd29c97356c71b51acf47ef6bcc.tar.bz2 rails-09cec7824800bdd29c97356c71b51acf47ef6bcc.zip |
Default mime type for XML should be application/xml [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3849 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/mime_type.rb | 29 | ||||
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 12 |
2 files changed, 28 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index 6a33fdc19a..13b00c5984 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -30,27 +30,30 @@ module Mime end end - ALL = Type.new "*/*", :all - HTML = Type.new "text/html", :html - JS = Type.new "text/javascript", :js, %w( application/javascript application/x-javascript ) - XML = Type.new "text/xml", :xml, %w( application/xml application/x-xml ) - RSS = Type.new "application/rss+xml", :rss - ATOM = Type.new "application/atom+xml", :atom - YAML = Type.new "application/x-yaml", :yaml + 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 ) + RSS = Type.new "application/rss+xml", :rss + ATOM = Type.new "application/atom+xml", :atom + YAML = Type.new "application/x-yaml", :yaml LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) } LOOKUP["*/*"] = ALL + LOOKUP["text/html"] = HTML - LOOKUP["application/rss+xml"] = RSS - LOOKUP["application/atom+xml"] = ATOM - LOOKUP["application/x-yaml"] = YAML + LOOKUP["application/xhtml+xml"] = HTML + + LOOKUP["application/xml"] = XML + LOOKUP["text/xml"] = XML + LOOKUP["application/x-xml"] = XML LOOKUP["text/javascript"] = JS LOOKUP["application/javascript"] = JS LOOKUP["application/x-javascript"] = JS - LOOKUP["text/xml"] = XML - LOOKUP["application/xml"] = XML - LOOKUP["application/x-xml"] = XML + LOOKUP["application/rss+xml"] = RSS + LOOKUP["application/atom+xml"] = ATOM + LOOKUP["application/x-yaml"] = YAML end
\ No newline at end of file diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 159d57f1c3..6fcaaf302d 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -183,4 +183,16 @@ class MimeControllerTest < Test::Unit::TestCase get :custom_type_handling assert_equal 'HTML', @response.body end + + def test_xhtml_alias + @request.env["HTTP_ACCEPT"] = "application/xhtml+xml,application/xml" + get :html_or_xml + assert_equal 'HTML', @response.body + end + + def test_firefox_simulation + @request.env["HTTP_ACCEPT"] = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + get :html_or_xml + assert_equal 'HTML', @response.body + end end
\ No newline at end of file |