From afeee2923ff8340e4d9b8027a0d32b26bfcef17f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 28 Mar 2012 18:44:02 +0100 Subject: [PATCH 1/1] Send a Content-Length header when streaming a file --- config/initializers/streaming.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/initializers/streaming.rb b/config/initializers/streaming.rb index 0fc092951..db61e6b24 100644 --- 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 -- 2.43.2