You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by em...@thefreecat.org on 2007/10/02 04:53:59 UTC

Raising error early

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 ?

Thanks in advance,

JC

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org