Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 09cec7824800bdd29c97356c71b51acf47ef6bcc 1 parent e3ea34f
@dhh dhh authored
View
29 actionpack/lib/action_controller/mime_type.rb
@@ -30,27 +30,30 @@ def ==(mime_type)
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
12 actionpack/test/controller/mime_responds_test.rb
@@ -183,4 +183,16 @@ def test_custom_types
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
Please sign in to comment.
Something went wrong with that request. Please try again.