diff --git a/activestorage/app/controllers/concerns/active_storage/file_server.rb b/activestorage/app/controllers/concerns/active_storage/file_server.rb index 1b9f2db9ff..cdb9c35b8a 100644 --- a/activestorage/app/controllers/concerns/active_storage/file_server.rb +++ b/activestorage/app/controllers/concerns/active_storage/file_server.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/hash/except" + module ActiveStorage::FileServer # :nodoc: private def serve_file(path, content_type:, disposition:) @@ -11,6 +13,7 @@ def serve_file(path, content_type:, disposition:) response.headers[name] = value end + response.headers.except!("X-Cascade", "x-cascade") if status == 416 response.headers["Content-Type"] = content_type || DEFAULT_SEND_FILE_TYPE response.headers["Content-Disposition"] = disposition || DEFAULT_SEND_FILE_DISPOSITION end diff --git a/activestorage/test/controllers/disk_controller_test.rb b/activestorage/test/controllers/disk_controller_test.rb index 98e2d687fc..4c5b24aa28 100644 --- a/activestorage/test/controllers/disk_controller_test.rb +++ b/activestorage/test/controllers/disk_controller_test.rb @@ -32,6 +32,12 @@ class ActiveStorage::DiskControllerTest < ActionDispatch::IntegrationTest assert_equal " worl", response.body end + test "showing blob with invalid range" do + blob = create_blob + get blob.url, headers: { "Range" => "bytes=1000-1000" } + assert_response :range_not_satisfiable + end + test "showing blob that does not exist" do blob = create_blob blob.delete