Hello, this has been throwing me off for too long..
Posted below is our Rails 3 controller.
When attempting to access with Internet Explorer the first time, the download prompt fails with a "Unable to download" message.
When attempting to access the same URL immediately following, the download prompt works successfully.
In any instance, the Cache-Control header is not being sent properly either. We are providing a specific value to the Rack Response, yet the Cache-Control is always being returned as "Cache-Control: no-cache". The other header values provided are being sent correctly though. This may be a separate question, but throwing me off regardless.
The sample below is a mock of how our actual system works with client data. A CSV is started and streamed to the client. The download is progressive, to avoid a long wait time while the CSV generation is complete. These files can be upwards of 20-30mb, so waiting a few minutes before a download starts is not desirable.
This appears to be working in all other browsers (firefox, safari, etc).
class StreamingController < ApplicationController
def index
respond_to do |wants|
wants.csv {
filename = "testing_filename#{DateTime.now}.csv"
headers.merge!({
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Content-Type' => 'text/csv',
'Content-Disposition' => "attachment; filename=\"#{filename}\"",
'Content-Transfer-Encoding' => 'binary'
})
responder = Rack::Response.new([], 200, headers) do |response|
response.finish do |r|
100000.times do |t|
r.write(t)
end
end
end
self.response_body = responder
}
end
end
end