diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-12-31 08:08:16 -0800 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-12-31 08:08:16 -0800 |
commit | e48dc194231830f42f179704596b88215f062c23 (patch) | |
tree | fd53e7bbfd00af4ff8fbc82be958de539c247d9e /actionpack/lib | |
parent | d38c8caa48a732d41c7402a5e71deece4e313559 (diff) | |
parent | 55a886b6e9bae1986a357626b08522a838aedb3e (diff) | |
download | rails-e48dc194231830f42f179704596b88215f062c23.tar.gz rails-e48dc194231830f42f179704596b88215f062c23.tar.bz2 rails-e48dc194231830f42f179704596b88215f062c23.zip |
Merge pull request #8665 from senny/8661_should_not_append_charset_if_already_present
backport #8662, charset should not be appended for `head` responses
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/head.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb index 671053566d..4c61bbd6dc 100644 --- a/actionpack/lib/action_controller/metal/head.rb +++ b/actionpack/lib/action_controller/metal/head.rb @@ -29,6 +29,7 @@ module ActionController self.status = status self.location = url_for(location) if location self.content_type = content_type || (Mime[formats.first] if formats) + self.response.charset = false if self.response self.response_body = " " end end diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 5797c63924..60d97c5e77 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -56,7 +56,7 @@ module ActionDispatch # :nodoc: CONTENT_TYPE = "Content-Type".freeze SET_COOKIE = "Set-Cookie".freeze LOCATION = "Location".freeze - + cattr_accessor(:default_charset) { "utf-8" } include Rack::Response::Helpers @@ -195,12 +195,16 @@ module ActionDispatch # :nodoc: return if headers[CONTENT_TYPE].present? @content_type ||= Mime::HTML - @charset ||= self.class.default_charset + @charset ||= self.class.default_charset if !defined?(@charset) || @charset != false type = @content_type.to_s.dup - type << "; charset=#{@charset}" unless @sending_file + type << "; charset=#{@charset}" if append_charset? headers[CONTENT_TYPE] = type end + + def append_charset? + !@sending_file && @charset != false + end end end |