perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kolikov <koli...@free.fr>
Subject Re: Raising error early
Date Tue, 02 Oct 2007 19:37:27 GMT
embperl@thefreecat.org a écrit :
 > Hi,
 >
 > In order to do some tracking on the PDF downloaded on our
 > site, I have modified my _base.epl and send the file
 > "by hand" :
 >
 > if (open(PDF,$ENV{DOCUMENT_ROOT}.$ENV{SCRIPT_NAME})) {
 >   $http_headers_out{'Content-type'}='application/pdf';
 >   $http_headers_out{'Content-Disposition'}='attachment; 
filename=$filename';
 >   local ($/);
 >   local ($escmode);
 >   my $pdf=<PDF>;
 >   print OUT $pdf;
 >   close(PDF);
 > }
 > else {
 >   $http_headers_out{'Location'}=["http://$ENV{SERVER_NAME}",404];
 >   exit;
 > }
 > But if the file is missing, I would like to redirect to
 > the 404 page. Currently, I get the popup
 > asking what to do with the pdf (open with/save to disk...)
 > and if I accept I get an empty file (of course).
 >
 > Is there a way to mimic the default behaviour ?

I don't catch it.

The opened file is your own script, so the open is always true.
When I test the code, the pdf I download is the script itself...
The content-type header is good.
The Content-Disposition doesn't seem to make any attachement.
And I can't figure out why.

Anyway the 404 test should be -f "/the/path/to/the/pdf/file.pdf"

Or am I missing something ?



Bregs,
-- 
Nuguet romuald : kolikov@free.fr

Mime
View raw message