projects
/
rails.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e3a6b81
)
Send a Content-Length header when streaming a file
author
Tom Hughes
<tom@compton.nu>
Wed, 28 Mar 2012 17:44:02 +0000
(18:44 +0100)
committer
Tom Hughes
<tom@compton.nu>
Wed, 28 Mar 2012 17:44:02 +0000
(18:44 +0100)
config/initializers/streaming.rb
patch
|
blob
|
history
diff --git
a/config/initializers/streaming.rb
b/config/initializers/streaming.rb
index 0fc0929511628a768927581ca9ac6f0054f33596..db61e6b24041069f478d5ef09a5b5f2076155ab3 100644
(file)
--- a/
config/initializers/streaming.rb
+++ b/
config/initializers/streaming.rb
@@
-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