Merge pull request #3878 from kennyj/should_use_default_charset
Use default charset when we read content type without charset.
This commit is contained in:
commit
eb22901920
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user