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

Merge pull request #29777 from yui-knk/set_content_type

Refactoring `Response#charset=`
This commit is contained in:
Matthew Draper 2017-08-02 19:09:34 +09:30 committed by GitHub
commit 8e32171458

View file

@ -259,11 +259,10 @@ module ActionDispatch # :nodoc:
# response.charset = 'utf-16' # => 'utf-16'
# response.charset = nil # => 'utf-8'
def charset=(charset)
header_info = parsed_content_type_header
content_type = parsed_content_type_header.mime_type
if false == charset
set_header CONTENT_TYPE, header_info.mime_type
set_content_type content_type, nil
else
content_type = header_info.mime_type
set_content_type content_type, charset || self.class.default_charset
end
end