Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Write PerlPostReadRequestHandler

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


marcodisano at gmail

May 19, 2011, 1:30 AM

Post #1 of 6 (791 views)
Permalink
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("<html><body>ciao mondo</body></html>");

I add to the end of httpd.conf file this:

Alias /perl/ /home/marcolino/perlScript/
<Location /perl/ >
SetHandler perl-script
PerlResponseHandler touch.pl
Allow from all
</Location>
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


rafiq at joshua

May 19, 2011, 7:05 AM

Post #2 of 6 (779 views)
Permalink
Re: Write PerlPostReadRequestHandler [In reply to]

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.


aw at ice-sa

May 19, 2011, 7:32 AM

Post #3 of 6 (774 views)
Permalink
Re: Write PerlPostReadRequestHandler [In reply to]

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


marcodisano at gmail

May 19, 2011, 7:47 AM

Post #4 of 6 (775 views)
Permalink
Re: Write PerlPostReadRequestHandler [In reply to]

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.


marcodisano at gmail

May 19, 2011, 8:02 AM

Post #5 of 6 (772 views)
Permalink
Re: Write PerlPostReadRequestHandler [In reply to]

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?


rafiq at joshua

May 20, 2011, 2:16 AM

Post #6 of 6 (765 views)
Permalink
Re: Write PerlPostReadRequestHandler [In reply to]

Marco,

On Thu, 19 May 2011, marco wrote:

> Il 19/05/2011 16.47, marco ha scritto:
> Il 19/05/2011 16.32, Andr? Warnier ha scritto:
> On Thu, 19 May 2011, marco wrote:
> ...
> PerlPostReadRequestHandler touch.pl
>
>                              ^^^^^^^^
> This should be the package name of a module on your @INC path.
>
> - rename your script to "touch.pm"  (a convention, for mod_perl handler modules)
> Sorry, i have posted the wrong code. The correct one is the follow, (as you suggest me there is OK):
>  #touch.pm
>   #-------------

>
> With this code the server give me the same error(white page + in the
> error_log file it prints "failed to resolve handler touch")

See perldoc perlmod (http://perldoc.perl.org/perlmod.html) You need
to implement a perl module and I'd recommend some study into modularising
perl prior to your diving into implementing a custom handler.

Good luck.
Raf

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.