[cgiapp] redirect/content type

Benjamin Hitz hitz at genome.stanford.edu
Wed Jun 11 19:41:50 EDT 2008

This is probably a vanilla CGI question, but I am working under CGIapp  
so here goes.

I have a cgi::app that shows a table.  I want to have a link which  
generates a plain text (tab delim) version of the table, and pops up a  
"save as" window.

Prior to cgi-app we just wrote a temp file on the server, and added a  
link to it - this doesn't set the correct MIME type so if you click on  
it it shows you the file in the browser (not what you want usually).

I have a run mode in my cgi-app to generate the file, but I seem to  
have two mildly unsatisfying option:

1) write a tmp file on the server, and use redirect to get the txt  
file... but I cannot seem to sent the Content-Type: on the redirect (I  
even tried faking the header in the txt file).

2) change the header with $self->header('-type' -> 'application/octet- 
stream') and return the text in the run mode.  This gives me the  
"download" option (MIME type set correctly) but the file name appears  
as "myscript.pl" and says it's a perl source.

Some way to set BOTH a redirect and a content-type?   Or simply fake  
the name name of the file?


Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO  
Stanford University ** hitz at genome.stanford.edu

More information about the cgiapp mailing list