[LRUG] IE headers and exporting data in CSV files
Joel Chippindale
joel.chippindale at gmail.com
Tue Aug 4 04:35:10 PDT 2009
I've seen the following hack for setting the headers for IE in Ruby on Rails
when serving CSV files all over the place (for example
http://vikasnandal.blogspot.com/2008/03/how-to-export-data-to-csv-in-ruby-on.html
).
However I've never seen an explanation as to why it might be needed.
Can any of you knowledgeable LRUGers enlighten
me as to what the problem with IE that it is meant to resolve is and if so,
which versions of IE it is a problem with and
finally what happens if you don't include do these IE specific headers?
#this is required if you want this to work with IE
if request.env['HTTP_USER_AGENT'] =~ /msie/i
headers['Pragma'] = 'public'
headers["Content-type"] = "text/plain"
headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0,
pre-check=0'
headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""
headers['Expires'] = "0"
else
headers["Content-Type"] ||= 'text/csv'
headers["Content-Disposition"] = "attachment; filename=\"#{filename}\""
end
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20090804/d8311d32/attachment-0003.html>
More information about the Chat
mailing list