List Info

Thread: Re: Raising error early




Re: Raising error early
country flaguser name
France
2007-10-02 14:37:27
embperlthefreecat.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.$ENV))
{
 >  
$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",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 : kolikovfree.fr

------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
For additional commands, e-mail: embperl-helpperl.apache.org
Re: Raising error early
user name
2007-10-02 15:29:37
Hello my friend  Nice to
see an answer from you !

kolikov a écrit :
>  > site, I have modified my _base.epl and send the
file
>  > "by hand" :

 > The opened file is your own script, so the open is
always true.

No. My _base.epl (EMBPERL_OBJECT_BASE) is being called for
every
.pdf file. This is part of my apache2 conf :

       [...]
       EMBPERL_OBJECT_BASE  base.epl
       <FilesMatch ".(pdf|html)$">
          SetHandler  perl-script
          PerlHandler Embperl::Object
          Options     ExecCGI
       </FilesMatch>
       [...]

This way, every .pdf file to be transmitted to the user
gets
called via my script. So I'm sure *every* *single* pdf
download
in the site gets logged. And it's completely transparent for
the
user : no popup, normal link, no javascript, no forgotten
pdf : a dream.

After hours of investigations, it seems firefox was having
strange
behaviour when WebDeveloper extension had the "Disable
cache"
checked. It was like permanent, even ctrl-F5 would not
refresh.

Now it's working fine. Will put in prod tomorrow. You know
the
address for ecm... If you want to have a look. I can send
you
the complete source (and apache config) if you like.

Thanks for your help anyway, cu!

Jc

------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
For additional commands, e-mail: embperl-helpperl.apache.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )