1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
David Heinemeier Hansson 2006-03-12 18:50:14 +00:00
parent e3ea34f7d3
commit 09cec78248
2 changed files with 28 additions and 13 deletions

View file

@ -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

View file

@ -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