プロジェクト

全般

プロフィール

Vote #78068

完了

X-Sendfile is missing in response headers

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
124
issue_org_id:
24646
author_id:
12557
assigned_to_id:
1
comments:
8
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
122
ステータス-->[Closed]

説明

Despite uncommenting X-Sendfile option in config/additional_environment.rb, X-Sendfile header is not added into the response. Therefore the download is not handed over to the webserver and it is processed by the application. It prevents from downloading of large files.

config/additional_environment.rb

# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"

Response header when downloading a file from the Files module:

Cache-Control private
Connection Keep-Alive
Content-Disposition attachment; filename="file.zip"
Content-Length 25362
Content-Type application/x-zip-compressed
Date Mon, 19 Dec 2016 08:33:42 GMT
Etag "c4c34e17fd91b5e7f97ea03a1e4366f6"
Server WEBrick/1.3.1 (Ruby/2.3.1/2016-04-26)
Set-Cookie _redmine_session=SzJycUd0VUYybGNkU2NVWGVHN1VQOVhJVUY1dTJCRjNOS05HU2xaSzY1aWYwOHp3am1SUURiWEdjNCtZOE44T2I0UkV3eHNWSWwwZDJ0MHBUMmhjck5Vd3ZNVHZla1RNTXBTTWQ3bnQva2p4OXk1KzUxcFgzWmVmU0dlYWg2dXFtei9JRXpXYWpyQXJ1ckY2TlQ0WEtkb1dPclprSlJ5Ni9pejN0a0FXMkUrVFdTUVFUeDBlMW9DNGJuN0k5Y3dPM1FIekcxUDByZlQ4emg1TmJyVUdkdC84REwyU1pVNGtIZnkzTVJ4T1dDdnVIYTFPMWJBWFNZeU5DRlRSUkE3QytUc3dFbWRaMXdhUjZmK0FvcGlENklCV3YzTDhSbWt4YWs5UEJLdW9wczlFMy9yc3BlY3krakV1ZjlSeUdNN29Gd2tENnk3Vk5VOFlSMERkdVdxNVpjdG1xQ3RTQlNTYWRnb1QvVmVzZy9NPS0tVGFOZGhaWUZVdEdRMUJrSjMwU05pQT09--150df285ffe701a4ef1e1bad01398101dcb4989c; path=/; HttpOnly
X-Content-Type-Options nosniff
X-Frame-Options SAMEORIGIN
X-Request-Id 8743fb81-42d3-4924-b93f-199b95e68ed1
X-Runtime 0.030291
X-XSS-Protection 1; mode=block
content-transfer-encoding binary

My environment:

Environment:
  Redmine version                3.3.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
  Rails version                  4.2.7.1
  Environment                    production
  Database adapter               Mysql2

journals

During a next investigation I've found that the problem is that the body doesn't respond to *to_path* method:

<pre>
Rack::Sendfile

class Sendfile
F = ::File
...

def call(env)
status, headers, body = @app.call(env)
if body.respond_to?(:to_path) # Here is the problem
case type = variation(env)
when 'X-Accel-Redirect'
...
</pre>

While in a working application the body is an instance of ActionDispatch::Response::RackBody which have as a member ActionDispatch::Response response, in Redmine I see there an array which doesn't respond to to_path method.

Unfortunately I've no clue what could be the reason.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
The problem was caused by Rack::ContentLength. This should be fixed by r16114.
Thanks for pointing this out.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
I confirm that after applying your patch, everything works as expected. Thank you very much.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Thanks for the feedback.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,32785,X-Sendfile header field is not set if rack 2.1.0 is installed

Admin Redmine さんが3年以上前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン3.2.5_124 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0