Merge pull request #45911 from fatkodima/invalid-range-disk-controller
[ActiveStorage] Return "Range Not Satisfiable" return code for partial downloads with incorrect range
This commit is contained in:
commit
d96612d3ca
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user