From a5ded9d884379179aa0e05e6cdfa11c674749162 Mon Sep 17 00:00:00 2001 From: Paul Barry Date: Fri, 26 Sep 2008 12:40:40 -0400 Subject: [PATCH] Added value of false as a valid value for the disposition option of send_file --- actionpack/lib/action_controller/streaming.rb | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/actionpack/lib/action_controller/streaming.rb b/actionpack/lib/action_controller/streaming.rb index 333fb61..b444de7 100644 --- a/actionpack/lib/action_controller/streaming.rb +++ b/actionpack/lib/action_controller/streaming.rb @@ -109,7 +109,8 @@ module ActionController #:nodoc: # * :filename - suggests a filename for the browser to use. # * :type - specifies an HTTP content type. Defaults to 'application/octet-stream'. # * :disposition - specifies whether the file will be shown inline or downloaded. - # Valid values are 'inline' and 'attachment' (default). + # Valid values are 'inline', 'attachment' (default) and false, which omit the + # 'Content-Disposition'. # * :status - specifies the status code to send with the response. Defaults to '200 OK'. # # Generic data download: @@ -134,19 +135,20 @@ module ActionController #:nodoc: private def send_file_headers!(options) + unless options[:disposition] == false + disposition = options[:disposition].dup || 'attachment' + disposition <<= %(; filename="#{options[:filename]}") if options[:filename] + headers.update('Content-Disposition' => disposition) + end + options.update(DEFAULT_SEND_FILE_OPTIONS.merge(options)) - [:length, :type, :disposition].each do |arg| + [:length, :type].each do |arg| raise ArgumentError, ":#{arg} option required" if options[arg].nil? end - - disposition = options[:disposition].dup || 'attachment' - - disposition <<= %(; filename="#{options[:filename]}") if options[:filename] - + headers.update( 'Content-Length' => options[:length], 'Content-Type' => options[:type].to_s.strip, # fixes a problem with extra '\r' with some browsers - 'Content-Disposition' => disposition, 'Content-Transfer-Encoding' => 'binary' ) -- 1.5.4