On Fri 05 Sep 2008, [EMAIL PROTECTED] wrote: > I want to generate a data file which should be downloaded by clients. > Rather than generate this file and put it in a web dir and tell > clients to download it, is there any way to generate the content > dynamicly and put it to cients? I mean I don't want to generate the > temporary file.
Plenty. For example in your httpd.conf <Location /download> SetHandler modperl PerlResponseHandler "sub { \ use Apache2::RequestRec (); \ use Apache2::RequestIO (); \ use Apache2::Connection (); \ $_[0]->content_type('application/octet-stream'); \ until($_[0]->connection->aborted) { \ $_[0]->print(rand); \ } \ return 0; \ }" </Location> Now restart your server and then curl -v http://server/download And you'll get never ending randomness. You can also write a little shell script and use it via mod_cgi: >>>>>>>>>>>>>>>>>> the shell script #!/bin/bash echo Content-Type: application/octet-stream echo cat /dev/urandom <<<<<<<<<<<<<<<<<< end of shell script Now fetch the Apache docs and configure your server to execute the script as CGI program. Remember it is not necessarily faster to send dynamic content this way. Sometimes it is faster to write a temporary file sometime before the response phase and let the default handler send it. If you decide to send the content on the fly try to figure out the content length and set the Content-Length header. This can also improve your performance. Torsten -- Need professional mod_perl support? Just hire me: [EMAIL PROTECTED]