]> source.dussan.org Git - redmine.git/commitdiff
Merged r16114 (#24646).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jan 2017 19:52:54 +0000 (19:52 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jan 2017 19:52:54 +0000 (19:52 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@16131 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/application.rb
test/integration/attachments_test.rb

index 96fa38b4986d51d44e19f4f827b3773a01922678..965edcec245da2faf68e7f9e458b7be5802eb521 100644 (file)
@@ -55,7 +55,7 @@ module RedmineApp
     config.middleware.insert_after ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser
 
     # Sets the Content-Length header on responses with fixed-length bodies
-    config.middleware.use Rack::ContentLength
+    config.middleware.insert_after Rack::Sendfile, Rack::ContentLength
 
     # Verify validity of user sessions
     config.redmine_verify_sessions = true
index 114e47a3a79ae05e494f4aa0d6eafd740ba518a0..ec76269537326cc8752c1dcb7c2aea743f8abb01 100644 (file)
@@ -136,6 +136,18 @@ class AttachmentsTest < Redmine::IntegrationTest
     assert_include "$('#attachments_1').remove();", response.body
   end
 
+  def test_download_should_set_sendfile_header
+    set_fixtures_attachments_directory
+    Rack::Sendfile.any_instance.stubs(:variation).returns("X-Sendfile")
+
+    get "/attachments/download/4"
+    assert_response :success
+    assert_not_nil response.headers["X-Sendfile"]
+
+  ensure
+    set_tmp_attachments_directory
+  end
+
   private
 
   def ajax_upload(filename, content, attachment_id=1)