提交 a1986e7d 编写于 作者: K kennyj

Use default charset when we read content type without charset.

上级 9be2353f
......@@ -69,7 +69,7 @@ def initialize(status = 200, header = {}, body = [])
if content_type = self["Content-Type"]
type, charset = content_type.split(/;\s*charset=/)
@content_type = Mime::Type.lookup(type)
@charset = charset || "UTF-8"
@charset = charset || self.class.default_charset
end
prepare_cache_control!
......
......@@ -130,6 +130,17 @@ def setup
assert_equal('application/xml; charset=utf-16', resp.headers['Content-Type'])
end
test "read content type without charset" do
original = ActionDispatch::Response.default_charset
begin
ActionDispatch::Response.default_charset = 'utf-16'
resp = ActionDispatch::Response.new(200, { "Content-Type" => "text/xml" })
assert_equal('utf-16', resp.charset)
ensure
ActionDispatch::Response.default_charset = original
end
end
end
class ResponseIntegrationTest < ActionDispatch::IntegrationTest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册