Dont set default charset if the response is sending a file. Closes #6689 [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5626 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2006-11-25 19:29:10 +00:00
parent cf248eae1f
commit 396b3f2bef
2 changed files with 13 additions and 1 deletions

View File

@ -1087,7 +1087,11 @@ module ActionController #:nodoc:
def assign_default_content_type_and_charset def assign_default_content_type_and_charset
response.content_type ||= Mime::HTML response.content_type ||= Mime::HTML
response.charset ||= self.class.default_charset response.charset ||= self.class.default_charset unless sending_file?
end
def sending_file?
response.headers["Content-Transfer-Encoding"] == "binary"
end end
def action_methods def action_methods

View File

@ -63,6 +63,14 @@ class SendFileTest < Test::Unit::TestCase
assert_equal file_data, response.body assert_equal file_data, response.body
end end
def test_headers_after_send_shouldnt_include_charset
response = process('data')
assert_equal "application/octet-stream", response.headers["Content-Type"]
response = process('file')
assert_equal "application/octet-stream", response.headers["Content-Type"]
end
# Test that send_file_headers! is setting the correct HTTP headers. # Test that send_file_headers! is setting the correct HTTP headers.
def test_send_file_headers! def test_send_file_headers!
options = { options = {