httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernard T. Higonnet" <...@higonnet.net>
Subject Re: Probably OT. Difficulty implementing content handler Apache2
Date Fri, 10 Jul 2009 09:02:11 GMT
Joe Lewis wrote:
> Bernard T. Higonnet wrote:
>> Here's my system
>>
>> FreeBSD 7.1-RELEASE #0
>> Apache/2.2.8 (Unix) PHP/5.2.10 mod_perl/2.0.4 Perl/v5.8.8
>>
>> I'm trying to create a content-handler.
.
.
.
.

> After a few minutes of searching for some example code and slapping it 
> together, I have an apache configuration that demonstrates the use of 
> mod_perl :
> 
> _________CODE_START________
> 
> LoadModule perl_module modules/mod_perl.so
> PerlResponseHandler Apache2::example
> SetHandler modperl
> 
> <Perl>
> package Apache2::example;
> 
> use 5;
> use strict;
> use Apache2::RequestRec;
> use Apache2::RequestIO;
> use Apache2::Const -compile => qw(DECLINED OK LOG_DEBUG);
> use Apache2::Log -compile => qw(LOG_MARK);
> use APR::Const -compile => qw(ENOTIME);
> 
> sub handler {
>  my $r = shift();
> #  $r->log_rerror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_DEBUG, 
> APR::Const::ENOTIME, "debug print");
>  $r->log_error("debug print");
> 
>  if ($r->uri =~ m%^/my/uri/to/test%) {
>    $r->content_type('text/html');
>    $r->puts(<<"END");
> <HTML><BODY>
> <H3>Hello</H3>
> Hello from <B>this</B>!
> </BODY></HTML>
> END
> 
>    return Apache2::Const::OK;
>  }
>  return Apache2::Const::DECLINED;
> };
> 
> 1;
> </Perl>
> _________CODE_FINISH________
> 
> Just paste that into a .conf file and include the .conf file into your 
> apache.  Then, restart, and point a web browser to your server using the 
> URI of /my/uri/to/test (e.g. http://example.com/my/uri/to/test).  You 
> should get a simple "hello!", and see a "debug print" in your apache log 
> file.  Keep in mind, with a module name like "Apache2::Footer", you 
> probably want it to alter the content of a page to add a footer rather 
> than create the complete content.
> 
> The replies in the one thread you provided a link to mention 
> content-handlers versus filters, but I think they meant "content 
> generators" instead of handlers.  The above is a content generator, not 
> a filter, and as such may not be what you need, but should give you a 
> good starting point.

First, thanks!

Well there must be something wrong with my server (as opposed to the handler code I'm trying
to 
use). I pasted your code verbatim (except its name) and I'm now 3 for 3, all with the same
result: 
nothing.

Am thinking of rebuilding the whole shebang, so that I will have all the latest versions and
a 
relatively clean slate.

Thanks again,
Bernard Higonnet

Mime
View raw message