# Making @headers\['Refresh'\] and send\_file work together?

**URL:** <https://www.ruby-forum.com/t/making-headers-refresh-and-send-file-work-together/57699>\
**Category:** Rails\
**Created:** [April 13, 2006, 4:10am UTC](https://www.ruby-forum.com/t/making-headers-refresh-and-send-file-work-together/57699 "2006-04-13T04:10:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![HSWade\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19adc/32.png) [@HSWade\_M](https://www.ruby-forum.com/u/HSWade_M)\
**Post date:** [April 13, 2006, 4:10am UTC](https://www.ruby-forum.com/t/making-headers-refresh-and-send-file-work-together/57699/1 "2006-04-13T04:10:17Z")

</div>

I’ve got a Rails 1.1 app where people can click a link to download a  
custom-generated file. The link to “Download Zip” goes to /  
controller/get\_zip. That action looks like this:

def get\_zip  
@cart = find\_cart  
ids = Array.new  
@cart.songs.each do |song|  
ids.push song.id  
end

```
 args = ids.join(" ")
 zipfile = `#{RAILS_ROOT}/perl/buildzip.pl #{args}`
 begin
   size = File.stat(zipfile).size
   @cart.empty!
   filename = "out.zip"
   send_file(zipfile, :filename => filename, :type =>

```

“application/zip”, :str  
eaming =\> false)  
rescue  
flash[:warning] = “Zip file no longer exists - did you already  
download it  
?”  
redirect\_to(:controller =\> “/online”)  
end  
end

I’d like to have the user get sent to a different page a few seconds  
after the download starts. In a previous incarnation of this app,  
I’d set the HTTP “Refresh” header before sending the binary data. In  
fact, on a standard controller action that just renders RHTML, I can do:

```
  @headers["Refresh"] = '5, url=http://www.cnn.com/'

```

And it works as expected - 5 seconds after the action is rendered,  
I’m redirected.

However, if I set that header before doing the send\_file, nothing  
happens. The file downloads properly - no problems there - but no  
redirect. Looking through the source, it doesn’t _seem_ like the  
@headers are getting overwritten, just updated. But it’s certainly  
not refreshing.

Any thoughts on how to make this work (or another way to accomplish  
what I’m trying to do?
