Write PerlPostReadRequestHandler
Hi, I tried to write an handler to be execute in the PostReadRequest phase of the http request cycle. here's the simple code (it is only a test): #file:touch.pl #- use strict; use warnings; use Apache::ServerUtil (); use Apache::RequestIO (); my $r = shift; $r->content_type('text/plain'); $r->print("ciao mondo"); I add to the end of httpd.conf file this: Alias /perl/ /home/marcolino/perlScript/ SetHandler perl-script PerlResponseHandler touch.pl Allow from all PerlPostReadRequestHandler touch.pl But I'm a little confused on what I wrote. I followed the ufficial guide but it was not very clear. When I link to http://localhost:81/ it gives me an INTERNAL ERROR. The error_log file contains: Warning: Use of "require" without parentheses is ambiguous at (eval 3) line 1. [Thu May 19 10:00:08 2011] [error] [client 127.0.0.1] failed to resolve handler `touch.pl': Can't locate touchpl in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl . /usr/local/apache) at (eval 3) line 1.\n ...(and more error of the same type)... Had some solve this problem or had someone write a PerlPostReadRequestHandler? Thanks
Re: Write PerlPostReadRequestHandler
http://perl.apache.org/docs/2.0/user/intro/start_fast.html On Thu, 19 May 2011, marco wrote: Hi, I tried to write an handler to be execute in the PostReadRequest phase of the http request cycle. #file:touch.pl ... PerlResponseHandler touch.pl ... PerlPostReadRequestHandler touch.pl This should be the package name of a module on your @INC path. But I'm a little confused on what I wrote. I followed the ufficial guide but it was not very clear. You might want to look at http://perl.apache.org/docs/2.0/user/intro/start_fast.html again. Good luck. R.
Re: Write PerlPostReadRequestHandler
Raf wrote: http://perl.apache.org/docs/2.0/user/intro/start_fast.html On Thu, 19 May 2011, marco wrote: Hi, I tried to write an handler to be execute in the PostReadRequest phase of the http request cycle. #file:touch.pl ... PerlResponseHandler touch.pl ... PerlPostReadRequestHandler touch.pl This should be the package name of a module on your @INC path. But I'm a little confused on what I wrote. I followed the ufficial guide but it was not very clear. You might want to look at http://perl.apache.org/docs/2.0/user/intro/start_fast.html again. More precisely, the section : "Handler Modules" The steps there are exactly what you need to do. Look carefully at the example perl code. - rename your script to "touch.pm" (a convention, for mod_perl handler modules) - change your script a bit, to resemble the example, with the sub handler { ... } 1; That "1;" at the end is very important. Also important is that your handler subroutine should return "OK" to Apache. Also change PerlPostReadRequestHandler touch.pl to PerlPostReadRequestHandler touch
Re: Write PerlPostReadRequestHandler
Il 19/05/2011 16.32, André Warnier ha scritto: Raf wrote: http://perl.apache.org/docs/2.0/user/intro/start_fast.html On Thu, 19 May 2011, marco wrote: Hi, I tried to write an handler to be execute in the PostReadRequest phase of the http request cycle. #file:touch.pl ... PerlResponseHandler touch.pl ... PerlPostReadRequestHandler touch.pl This should be the package name of a module on your @INC path. But I'm a little confused on what I wrote. I followed the ufficial guide but it was not very clear. You might want to look at http://perl.apache.org/docs/2.0/user/intro/start_fast.html again. More precisely, the section : "Handler Modules" The steps there are exactly what you need to do. Look carefully at the example perl code. - rename your script to "touch.pm" (a convention, for mod_perl handler modules) - change your script a bit, to resemble the example, with the sub handler { ... } 1; That "1;" at the end is very important. Also important is that your handler subroutine should return "OK" to Apache. Also change PerlPostReadRequestHandler touch.pl to PerlPostReadRequestHandler touch Hi Andrè, thanks for your help. The code I have written is the follow: *#touch.pm use strict; use warnings; use Apache2::ServerUtil (); use Apache2::RequestIO (); sub handler{ my $r = shift; $r->content_type('text/plain'); $r->print("ciao mondo"); } 1;* When I access to http://localhost:81/ on my Apache server, i have a white page and the *error_log* file contains: Warning: PHP Startup: Unable to load dynamic library 'ext/msql.so' - ext/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0 failed to resolve handler touch What's the matter? I don't understand what is the problem!! Any suggests is appreciated.
Re: Write PerlPostReadRequestHandler
Il 19/05/2011 16.47, marco ha scritto: Il 19/05/2011 16.32, André Warnier ha scritto: Raf wrote: http://perl.apache.org/docs/2.0/user/intro/start_fast.html On Thu, 19 May 2011, marco wrote: Hi, I tried to write an handler to be execute in the PostReadRequest phase of the http request cycle. #file:touch.pl ... PerlResponseHandler touch.pl ... PerlPostReadRequestHandler touch.pl This should be the package name of a module on your @INC path. But I'm a little confused on what I wrote. I followed the ufficial guide but it was not very clear. You might want to look at http://perl.apache.org/docs/2.0/user/intro/start_fast.html again. More precisely, the section : "Handler Modules" The steps there are exactly what you need to do. Look carefully at the example perl code. - rename your script to "touch.pm" (a convention, for mod_perl handler modules) - change your script a bit, to resemble the example, with the sub handler { ... } 1; That "1;" at the end is very important. Also important is that your handler subroutine should return "OK" to Apache. Also change PerlPostReadRequestHandler touch.pl to PerlPostReadRequestHandler touch Hi Andrè, thanks for your help. The code I have written is the follow: *#touch.pm use strict; use warnings; use Apache2::ServerUtil (); use Apache2::RequestIO (); sub handler{ my $r = shift; $r->content_type('text/plain'); $r->print("ciao mondo"); } 1;* When I access to http://localhost:81/ on my Apache server, i have a white page and the *error_log* file contains: Warning: PHP Startup: Unable to load dynamic library 'ext/msql.so' - ext/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0 failed to resolve handler touch What's the matter? I don't understand what is the problem!! Any suggests is appreciated. Sorry, i have posted the wrong code. The *correct* one is the follow, (as you suggest me there is OK): * #touch.pm #- use strict; use warnings; use Apache2::ServerUtil (); use Apache2::RequestIO (); use Apache2::Const -compile => 'OK'; sub handler{ open (MYFILE, '>> /home/marcolino/pippo'); print MYFILE "Marco on Apache\n"; close (MYFILE); #my $r = shift; #$r->content_type('text/plain'); #$r->print("ciao mondo"); return OK; } 1;* With this code the server give me the same error(white page + in the error_log file it prints "*failed to resolve handler touch*") What can i solve this?
Apache2::Cookie and cookie names
Hi All, In a modperl2 handler, using Apache2::Cookie, I have code as follows to fetch the names of the requests cookies: my @cookie_names = (eval { $cookie_jar->cookies() }); if ($@) { _oops("Could not parse cookies blah blah."); } I understand that with this code I either get all of the cookie names if they all can be parsed, or I get none of the cookie names if a parsing exception is thrown. Is there a way to get the names of all of the cookies that could be parsed up until the exception was thrown? I've seen in other postings this nifty example for getting the cookie jar: my $cookie_jar = eval { Apache2::Cookie::Jar->new($r) } || $@->jar; I'm wondering if there might be something as succinct and elegant as this for getting the cookie names. -James IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE: This message is intended for the use of the person to whom it is addressed and may contain information that is privileged, confidential, and protected from disclosure under applicable law. If you are not the intended recipient, your use of this message for any purpose is strictly prohibited. If you have received this communication in error, please delete the message and notify the sender so that we may correct our records.
Re: Deflate problem
Have you tried mod_deflate? On Sat, May 7, 2011 at 3:30 AM, Idel Fuschini wrote: > Hi people, > I've got this problem with DEFLATE. > This is my code example : > use strict; > use warnings; > use Apache2::Filter (); > use Apache2::RequestRec (); > use APR::Table (); > use Cache::FileBackend; > use Apache2::Const -compile => qw(OK); > use constant BUFF_LEN => 1024; > use vars qw($VERSION); > sub handler { > unless ($f->ctx) { > $f->r->headers_out->unset('Content-Length'); > $f->ctx(1); > } > > my $Hash=$f->r->subprocess_env(); > my $html_page="hello"; > my $content_type="text/html"; > my $len_bytes=length $html_page; > $f->r->headers_out->set("Content-Length"=>$len_bytes); > $f->r->headers_out->set("Last-Modified" => time()); > $f->r->content_type($content_type); > $f->print($html_page); > return Apache2::Const::OK; > } > This is my configuration on httpd.conf; > > PerlSetOutputFilter DEFLATE > PerlSetOutputFilter INCLUDES > SetHandler modperl > PerlOutputFilterHandler Apache2::AMFWebService > Allow from all > > I don't have any response on my browser, why ? > Thanks > Idel > = > Mobile: +39 349 442 2668 > E-Mail: idel.fusch...@gmail.com > Web Site: http://www.idelfuschini.it > OpenSource Project: Apache Mobile Filter - > http://www.idelfuschini.it/apache-mobile-filter-v2x.html > Test Page: http://www.apachemobilefilter.org/test/php_test.php > Mobile Test Page: http://www.apachemobilefilter.org > -- > La presente comunicazione ed i suoi allegati e' destinata esclusivamente > ai destinatari. Qualsiasi suo utilizzo, comunicazione o diffusione non > autorizzata > e' proibita. Se ha ricevuto questa comunicazione per errore, la preghiamo di > darne > immediata comunicazione al mittente e di cancellare tutte le informazioni > erroneamente acquisite. (Rif. D.Lgs. 196/2003). Grazie > > This message and its attachments are intended only for use by the > addressees. Any use, > re-transmission or dissemination not authorized of it is prohibited. If you > received > this e-mail in error, please inform the sender immediately and delete all > the material. > (Rif. D.Lgs. 196/2003). Thank you. >
Re: Deflate problem
yes the result is the same. Idel = Mobile: +39 349 442 2668 E-Mail: idel.fusch...@gmail.com Web Site: http://www.idelfuschini.it OpenSource Project: Apache Mobile Filter - http://www.idelfuschini.it/apache-mobile-filter-v2x.html Test Page: http://www.apachemobilefilter.org/test/php_test.php Mobile Test Page: http://www.apachemobilefilter.org -- La presente comunicazione ed i suoi allegati e' destinata esclusivamente ai destinatari. Qualsiasi suo utilizzo, comunicazione o diffusione non autorizzata e' proibita. Se ha ricevuto questa comunicazione per errore, la preghiamo di darne immediata comunicazione al mittente e di cancellare tutte le informazioni erroneamente acquisite. (Rif. D.Lgs. 196/2003). Grazie This message and its attachments are intended only for use by the addressees. Any use, re-transmission or dissemination not authorized of it is prohibited. If you received this e-mail in error, please inform the sender immediately and delete all the material. (Rif. D.Lgs. 196/2003). Thank you. On 19 May 2011 19:52, Fred Moyer wrote: > Have you tried mod_deflate? > > On Sat, May 7, 2011 at 3:30 AM, Idel Fuschini > wrote: > > Hi people, > > I've got this problem with DEFLATE. > > This is my code example : > > use strict; > > use warnings; > > use Apache2::Filter (); > > use Apache2::RequestRec (); > > use APR::Table (); > > use Cache::FileBackend; > > use Apache2::Const -compile => qw(OK); > > use constant BUFF_LEN => 1024; > > use vars qw($VERSION); > > sub handler { > > unless ($f->ctx) { > > $f->r->headers_out->unset('Content-Length'); > > $f->ctx(1); > > } > > > > my $Hash=$f->r->subprocess_env(); > > my $html_page="hello"; > > my $content_type="text/html"; > > my $len_bytes=length $html_page; > > $f->r->headers_out->set("Content-Length"=>$len_bytes); > > $f->r->headers_out->set("Last-Modified" => time()); > > $f->r->content_type($content_type); > > $f->print($html_page); > > return Apache2::Const::OK; > > } > > This is my configuration on httpd.conf; > > > >PerlSetOutputFilter DEFLATE > >PerlSetOutputFilter INCLUDES > >SetHandler modperl > >PerlOutputFilterHandler Apache2::AMFWebService > >Allow from all > > > > I don't have any response on my browser, why ? > > Thanks > > Idel > > = > > Mobile: +39 349 442 2668 > > E-Mail: idel.fusch...@gmail.com > > Web Site: http://www.idelfuschini.it > > OpenSource Project: Apache Mobile Filter - > > http://www.idelfuschini.it/apache-mobile-filter-v2x.html > > Test Page: http://www.apachemobilefilter.org/test/php_test.php > > Mobile Test Page: http://www.apachemobilefilter.org > > -- > > La presente comunicazione ed i suoi allegati e' destinata esclusivamente > > ai destinatari. Qualsiasi suo utilizzo, comunicazione o diffusione non > > autorizzata > > e' proibita. Se ha ricevuto questa comunicazione per errore, la preghiamo > di > > darne > > immediata comunicazione al mittente e di cancellare tutte le informazioni > > erroneamente acquisite. (Rif. D.Lgs. 196/2003). Grazie > > > > This message and its attachments are intended only for use by the > > addressees. Any use, > > re-transmission or dissemination not authorized of it is prohibited. If > you > > received > > this e-mail in error, please inform the sender immediately and delete all > > the material. > > (Rif. D.Lgs. 196/2003). Thank you. > > >
Re: Deflate problem
Please cc the list on your responses so that others can help answer in the event this scratch off lottery ticket here next to me has a big prize and I take off on vacation ;) For what it is worth, it looks like your code example contained a response handler and output filter in the same subroutine. You probably want to revisit the filter documentation on perl.apache.org. For instance, you set a content length header from $f; I don't know too many filters that know ahead of time what the length of the response will be until it is filtered. On Thu, May 19, 2011 at 11:23 AM, Idel Fuschini wrote: > yes the result is the same. > > On 19 May 2011 19:52, Fred Moyer wrote: >> >> Have you tried mod_deflate? >> >> On Sat, May 7, 2011 at 3:30 AM, Idel Fuschini >> wrote: >> > Hi people, >> > I've got this problem with DEFLATE. >> > This is my code example : >> > use strict; >> > use warnings; >> > use Apache2::Filter (); >> > use Apache2::RequestRec (); >> > use APR::Table (); >> > use Cache::FileBackend; >> > use Apache2::Const -compile => qw(OK); >> > use constant BUFF_LEN => 1024; >> > use vars qw($VERSION); >> > sub handler { >> > unless ($f->ctx) { >> > $f->r->headers_out->unset('Content-Length'); >> > $f->ctx(1); >> > } >> > >> > my $Hash=$f->r->subprocess_env(); >> > my $html_page="hello"; >> > my $content_type="text/html"; >> > my $len_bytes=length $html_page; >> > $f->r->headers_out->set("Content-Length"=>$len_bytes); >> > $f->r->headers_out->set("Last-Modified" => time()); >> > $f->r->content_type($content_type); >> > $f->print($html_page); >> > return Apache2::Const::OK; >> > } >> > This is my configuration on httpd.conf; >> > >> > PerlSetOutputFilter DEFLATE >> > PerlSetOutputFilter INCLUDES >> > SetHandler modperl >> > PerlOutputFilterHandler Apache2::AMFWebService >> > Allow from all >> > >> > I don't have any response on my browser, why ? >> > Thanks >> > Idel >> > = >> > Mobile: +39 349 442 2668 >> > E-Mail: idel.fusch...@gmail.com >> > Web Site: http://www.idelfuschini.it >> > OpenSource Project: Apache Mobile Filter - >> > http://www.idelfuschini.it/apache-mobile-filter-v2x.html >> > Test Page: http://www.apachemobilefilter.org/test/php_test.php >> > Mobile Test Page: http://www.apachemobilefilter.org >> > -- >> > La presente comunicazione ed i suoi allegati e' destinata esclusivamente >> > ai destinatari. Qualsiasi suo utilizzo, comunicazione o diffusione non >> > autorizzata >> > e' proibita. Se ha ricevuto questa comunicazione per errore, la >> > preghiamo di >> > darne >> > immediata comunicazione al mittente e di cancellare tutte le >> > informazioni >> > erroneamente acquisite. (Rif. D.Lgs. 196/2003). Grazie >> > >> > This message and its attachments are intended only for use by the >> > addressees. Any use, >> > re-transmission or dissemination not authorized of it is prohibited. If >> > you >> > received >> > this e-mail in error, please inform the sender immediately and delete >> > all >> > the material. >> > (Rif. D.Lgs. 196/2003). Thank you. >> > > >
Re: Deflate problem
On Saturday, May 07, 2011 12:30:56 Idel Fuschini wrote: > I've got this problem with DEFLATE. I think you either simply forgot to mention a PerlResponseHandler or you should omit the "SetHandler modperl". > >PerlSetOutputFilter DEFLATE >PerlSetOutputFilter INCLUDES >SetHandler modperl >PerlOutputFilterHandler Apache2::AMFWebService >Allow from all > Further, the order the filters will be called is this: INCLUDES ==> Apache2::AMFWebService ==> DEFLATE Torsten Förtsch -- Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net