Send a Content-Length header when streaming a file
This commit is contained in:
parent
e3a6b8183f
commit
afeee2923f
1 changed files with 4 additions and 0 deletions
|
@ -5,6 +5,8 @@ module ActionController
|
|||
|
||||
def send_file(file, options = {})
|
||||
if file.is_a? File or file.is_a? Tempfile
|
||||
headers["Content-Length"] ||= file.size.to_s
|
||||
|
||||
options[:filename] ||= File.basename(file.path) unless options[:url_based_filename]
|
||||
send_file_headers! options
|
||||
|
||||
|
@ -12,6 +14,8 @@ module ActionController
|
|||
self.content_type = options[:content_type] if options.key?(:content_type)
|
||||
self.response_body = file
|
||||
else
|
||||
headers["Content-Length"] ||= File.size(file).to_s
|
||||
|
||||
old_send_file(file, options)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue