From aef4a8a65bd690389dda2d2832e5a0c645b6d053 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 31 Dec 2016 12:45:36 +0000 Subject: [PATCH] Fixed that X-Sendfile header is never set (#24646). git-svn-id: http://svn.redmine.org/redmine/trunk@16114 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/application.rb | 2 +- test/integration/attachments_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 96fa38b49..965edcec2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/test/integration/attachments_test.rb b/test/integration/attachments_test.rb index 114e47a3a..ec7626953 100644 --- a/test/integration/attachments_test.rb +++ b/test/integration/attachments_test.rb @@ -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) -- 2.39.5