Re: Write PerlPostReadRequestHandler

marco <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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("<html><body><h1>ciao mondo</h1</body></html>");
>    }
>    1;*
>
> When I access to http://localhost:81/ on my Apache server, i have a 
> white page and the *error_log* file contains:
>
> <b>Warning</b>:  PHP Startup: Unable to load dynamic library 
> 'ext/msql.so' - ext/msql.so: cannot open shared object file: No such 
> file or directory in <b>Unknown</b> on line <b>0</b><br />
> 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("<html><body><h1>ciao mondo</h1</body></html>");
     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?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.