aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/streaming.rb
diff options
context:
space:
mode:
authorThomas Fuchs <thomas@fesch.at>2005-09-25 06:53:42 +0000
committerThomas Fuchs <thomas@fesch.at>2005-09-25 06:53:42 +0000
commit2346f5716f7b08168b74b29e0279d51c51557b08 (patch)
treeec368c97d55588ba6ee6bf9222d268345b1181da /actionpack/lib/action_controller/streaming.rb
parent2a35baa0bb4312d95e1340074cce731afedecde0 (diff)
downloadrails-2346f5716f7b08168b74b29e0279d51c51557b08.tar.gz
rails-2346f5716f7b08168b74b29e0279d51c51557b08.tar.bz2
rails-2346f5716f7b08168b74b29e0279d51c51557b08.zip
Fix open/save dialog in IE not opening files send with send_file/send_data, #2279
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/streaming.rb')
-rw-r--r--actionpack/lib/action_controller/streaming.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/streaming.rb b/actionpack/lib/action_controller/streaming.rb
index 0280522e13..2c4e76f359 100644
--- a/actionpack/lib/action_controller/streaming.rb
+++ b/actionpack/lib/action_controller/streaming.rb
@@ -120,6 +120,7 @@ module ActionController #:nodoc:
end
disposition = options[:disposition].dup || 'attachment'
+
disposition <<= %(; filename="#{options[:filename]}") if options[:filename]
@headers.update(
@@ -127,7 +128,15 @@ module ActionController #:nodoc:
'Content-Type' => options[:type].strip, # fixes a problem with extra '\r' with some browsers
'Content-Disposition' => disposition,
'Content-Transfer-Encoding' => 'binary'
- );
+ )
+
+ # Fix a problem with IE 6.0 on opening downloaded files:
+ # If Cache-Control: no-cache is set (which Rails does by default),
+ # IE removes the file it just downloaded from its cache immediately
+ # after it displays the "open/save" dialog, which means that if you
+ # hit "open" the file isn't there anymore when the application that
+ # is called for handling the download is run, so let's workaround that
+ @headers['Cache-Control'] = 'private' if @headers['Cache-Control'] == 'no-cache'
end
end
end \ No newline at end of file