Defect #32785

X-Sendfile header field is not set if rack 2.1.0 is installed

Added by Go MAEDA 11 months ago. Updated 11 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Attachments
Target version:4.0.7
Resolution:Fixed Affected version:

Description

$ bin/rails test test/integration/attachments_test.rb
Rack::File is deprecated, please use Rack::Files instead.
Run options: --seed 34165

# Running:

F

Failure:
AttachmentsTest#test_download_should_set_sendfile_header [/private/tmp/redmine-trunk/test/integration/attachments_test.rb:156]:
Expected nil to not be nil.

bin/rails test test/integration/attachments_test.rb:150

Related issues

Related to Redmine - Defect #24646: X-Sendfile is missing in response headers Closed

Associated revisions

Revision 19416
Added by Go MAEDA 11 months ago

X-Sendfile header field is not set if rack 2.1.0 is installed (#32785).

Revision 19417
Added by Go MAEDA 11 months ago

Merged r19416 from trunk to 4.1-stable (#32785).

Revision 19418
Added by Go MAEDA 11 months ago

Merged r19416 from trunk to 4.0-stable (#32785).

History

#1 Updated by Go MAEDA 11 months ago

Temporary fix for this issue:

diff --git a/Gemfile b/Gemfile
index f5428377d..657545d84 100644
--- a/Gemfile
+++ b/Gemfile
@@ -15,6 +15,9 @@ gem "nokogiri", "~> 1.10.0" 
 gem "i18n", "~> 1.6.0" 
 gem "rbpdf", "~> 1.20.0" 

+# TODO: Remove the following line when #32785 (AttachmentsTest fails if rack 2.1.0 is installed) is fixed
+gem 'rack', '~> 2.0.8'
+
 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
 gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]

#2 Updated by Pavel Rosický 11 months ago

this is related to https://www.redmine.org/issues/24646

@GO MAEDA take a look at https://github.com/rack/rack/pull/1463 for the potential fix

#3 Updated by Go MAEDA 11 months ago

  • Related to Defect #24646: X-Sendfile is missing in response headers added

#4 Updated by Go MAEDA 11 months ago

  • Subject changed from AttachmentsTest fails if rack 2.1.0 is installed to X-Sendfile header field is not set if rack 2.1.0 is installed
  • Category changed from Gems support to Attachments
  • Target version set to 4.0.7

Pavel Rosický wrote:

@GO MAEDA take a look at https://github.com/rack/rack/pull/1463 for the potential fix

Thank you, I have read the page and confirmed that the following patch fixes this issue.

diff --git a/config/application.rb b/config/application.rb
index a06ee4dba..86b695d42 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -60,7 +60,7 @@ module RedmineApp
     config.active_record.sqlite3.represent_boolean_as_integer = true

     # Sets the Content-Length header on responses with fixed-length bodies
-    config.middleware.insert_after Rack::Sendfile, Rack::ContentLength
+    config.middleware.insert_before Rack::Sendfile, Rack::ContentLength

     # Verify validity of user sessions
     config.redmine_verify_sessions = true

Setting the target version to 4.0.7.

#5 Updated by Go MAEDA 11 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix.

Also available in: Atom PDF