aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/response.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-12-20 05:01:42 +1030
committerMatthew Draper <matthew@trebex.net>2016-12-20 05:01:42 +1030
commit51a9311b2d31c77a70b2acc7c03fcd561184ff0d (patch)
tree6f21e888df478244221df4f3eea69e3feac932b3 /actionpack/lib/action_dispatch/http/response.rb
parent3582f58a7558dc0ddb3051b9deb5354aee378b5b (diff)
downloadrails-51a9311b2d31c77a70b2acc7c03fcd561184ff0d.tar.gz
rails-51a9311b2d31c77a70b2acc7c03fcd561184ff0d.tar.bz2
rails-51a9311b2d31c77a70b2acc7c03fcd561184ff0d.zip
Only default the response charset when it is first set
If it is explicitly cleared (e.g., response.sending_file = true), then we should not try to set it again.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/response.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index f71c6afd6c..516a2af69a 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -227,7 +227,9 @@ module ActionDispatch # :nodoc:
return unless content_type
new_header_info = parse_content_type(content_type.to_s)
prev_header_info = parsed_content_type_header
- set_content_type new_header_info.mime_type, new_header_info.charset || prev_header_info.charset || self.class.default_charset
+ charset = new_header_info.charset || prev_header_info.charset
+ charset ||= self.class.default_charset unless prev_header_info.mime_type
+ set_content_type new_header_info.mime_type, charset
end
# Sets the HTTP response's content MIME type. For example, in the controller