Skip to content

Commit

Permalink
Dont set default charset if the response is sending a file. Closes #6689
Browse files Browse the repository at this point in the history
 [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5626 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Nov 25, 2006
1 parent cf248ea commit 396b3f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion actionpack/lib/action_controller/base.rb
Expand Up @@ -1087,7 +1087,11 @@ def assign_names

def assign_default_content_type_and_charset
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

def action_methods
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/send_file_test.rb
Expand Up @@ -63,6 +63,14 @@ def test_data
assert_equal file_data, response.body
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.
def test_send_file_headers!
options = {
Expand Down

0 comments on commit 396b3f2

Please sign in to comment.