Re: content-disposition not recognized
And it was already documented here: http://perl.apache.org/docs/2.0/user/coding/coding.html#HTTP_Response_Headers -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
Micah Johnson wrote: --- Stas Bekman <[EMAIL PROTECTED]> wrote: Micah Johnson wrote: [...] print q[Content-type: text/plain\n] . q[Content-Disposition: attachment;filename=results.xml\n\n]. Thanks! The local $| = 0 trick works. Would you mind explaining what is happening? FYI, putting the headers on one print doesn't seem to fix it. Micah, please describe the outcome with the second approach. Do you still get 500 or just the headers are wrong? should there be a white space before 'filename='? I inherited this CGI and just tried to make it work as-is. If I put it all in one line and remove all the whitespace, it works without the buffering trick. My apologies, you can't use q[] with \n, it must be qq[]. So this should work: print qq[Content-type: text/plain\n] . qq[Content-Disposition: attachment;filename=results.xml\n\n]. or even more readable: print < END -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
--- Stas Bekman <[EMAIL PROTECTED]> wrote: > Micah Johnson wrote: > [...] > >>print q[Content-type: text/plain\n] . > >>q[Content-Disposition: > >>attachment;filename=results.xml\n\n]. > > > > > > Thanks! > > The local $| = 0 trick works. Would you mind > > explaining what is happening? FYI, putting the > > headers on one print doesn't seem to fix it. > > Micah, please describe the outcome with the second > approach. Do you still > get 500 or just the headers are wrong? should there > be a white space > before 'filename='? I inherited this CGI and just tried to make it work as-is. If I put it all in one line and remove all the whitespace, it works without the buffering trick. Thanks again, you da man, Micah __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
Micah Johnson wrote: [...] print q[Content-type: text/plain\n] . q[Content-Disposition: attachment;filename=results.xml\n\n]. Thanks! The local $| = 0 trick works. Would you mind explaining what is happening? FYI, putting the headers on one print doesn't seem to fix it. Micah, please describe the outcome with the second approach. Do you still get 500 or just the headers are wrong? should there be a white space before 'filename='? -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
Micah Johnson wrote: and the script prints headers like this: print "Content-type: text/plain\n"; print "Content-Disposition: attachment; filename=results.xml\n\n"; The resulting file reports a server error 500, premature end of script headers and the content-disposition line is displayed, so it looks like it is not being treated as a header. Try to add: local $| = 0; before sending headers, or send the header at once: print q[Content-type: text/plain\n] . q[Content-Disposition: attachment;filename=results.xml\n\n]. Thanks! The local $| = 0 trick works. Would you mind explaining what is happening? FYI, putting the headers on one print doesn't seem to fix it. As soon as you send some content to the client, Apache sends the headers immediately (since there is no send_http_header() in Apache 2.0). So when you do: print q[Content-type: text/plain\n]; Apache sends httpd headers right away, before it sees extra headers. By making the output buffered $! (which is the case by default) you delay sending the data out, till the 8K buffer is filled (or the request is completed). But it's probably a better practice to send the header at once as I've suggested, rather than relying on the buffering feature. -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
> > and the script prints headers like this: > > > > print "Content-type: text/plain\n"; > > print "Content-Disposition: attachment; > > filename=results.xml\n\n"; > > > > The resulting file reports a server error 500, > > premature end of script headers and the > > content-disposition line is displayed, so it looks > > like it is not being treated as a header. > > Try to add: > >local $| = 0; > > before sending headers, or send the header at once: > > print q[Content-type: text/plain\n] . > q[Content-Disposition: > attachment;filename=results.xml\n\n]. Thanks! The local $| = 0 trick works. Would you mind explaining what is happening? FYI, putting the headers on one print doesn't seem to fix it. --Micah __ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: content-disposition not recognized
Micah Johnson wrote: I am having difficulty sending an XML file to the browser using the Content-Disposition: attachment header. I am running mod_perl/1.99_13 and trying to use an existing cgi script which returns data in various forms. One is an XML file. The script is found in a directory setup like this: SetHandler perl-script PerlResponseHandler ModPerl::PerlRun PerlOptions +ParseHeaders Options ExecCGI and the script prints headers like this: print "Content-type: text/plain\n"; print "Content-Disposition: attachment; filename=results.xml\n\n"; The resulting file reports a server error 500, premature end of script headers and the content-disposition line is displayed, so it looks like it is not being treated as a header. Try to add: local $| = 0; before sending headers, or send the header at once: print q[Content-type: text/plain\n] . q[Content-Disposition: attachment;filename=results.xml\n\n]. Any suggestions on how to fix this? Unrelated, better upgrade to the latest 1.99_17, to avoid problems that were already fixed. -- __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html