]> source.dussan.org Git - redmine.git/commitdiff
scm: set mime type in downloading file.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 22 Mar 2011 16:56:52 +0000 (16:56 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 22 Mar 2011 16:56:52 +0000 (16:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5210 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/repositories_controller.rb
test/functional/repositories_filesystem_controller_test.rb
test/functional/repositories_mercurial_controller_test.rb

index a4719423eafe945e23d1d680b6789c54b25379a0..475472509518b39e7dac6225dfd9997104bbec18 100644 (file)
@@ -127,7 +127,10 @@ class RepositoriesController < ApplicationController
          (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
          ! is_entry_text_data?(@content, @path)
       # Force the download
-      send_data @content, :filename => filename_for_content_disposition(@path.split('/').last)
+      send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
+      send_type = Redmine::MimeType.of(@path)
+      send_opt[:type] = send_type.to_s if send_type
+      send_data @content, send_opt
     else
       # Prevent empty lines when displaying a file with Windows style eol
       # TODO: UTF-16
index aa090d3aba0d39bd76b161337f60b07a660d621c..5df8865678378df792a9b1703ffc3bbcb053a9f5 100644 (file)
@@ -98,8 +98,7 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
       with_settings :file_max_size_displayed => 1 do
         get :entry, :id => PRJ_ID, :path => ['japanese', 'big-file.txt']
         assert_response :success
-        # TODO: 'text/plain'
-        assert_equal 'application/octet-stream', @response.content_type
+        assert_equal 'text/plain', @response.content_type
       end
     end
   else
index 8247bcb007c65d7e991bc0c0650e48f72dfa9ff4..0c638df12a1d2a70bdb3c2d173af3a643710a5b3 100644 (file)
@@ -222,8 +222,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
     def test_entry_binary_force_download
       get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
       assert_response :success
-      # TODO: 'image/png'
-      assert_equal 'application/octet-stream', @response.content_type
+      assert_equal 'image/png', @response.content_type
     end
 
     def test_directory_entry