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.
I know that Apache finds the handler because if there's a syntax error
in the perl, Apache reports
the error.
If however, there is no syntax error, everything falls into a deep
dark hole: the browser (Firefox
3.0a2 under FreeBSD and Firefox 3.5 under XP) shows a beautiful empty
screen while both access and
error logs for Apache have no knowledge of the request. IE6 under XP
says "This page cannot be
displayed" and asserts a server or DNS error. So I conclude that
Apache sends nothing at all back to
the browser.
I know the feeling all too well.
This happens no matter what the code is, code which I have lifted from
the Internet such as
http://cpansearch.perl.org/src/GOZER/mod_perl-2.0.1/docs/os/win32/config.pod)
or
http://www.gossamer-threads.com/lists/modperl/modperl/99882
The Apache conf file has this in it
<Location /public/footer>
SetHandler modperl
PerlResponseHandler Apache2::Footer
</Location>
I apologize for mailing to this list but have not found a better a
place...
TIA
Bernard Higonnet
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.
Joe
--
Joe Lewis
Chief Nerd SILVERHAWK <http://www.silverhawk.net/> (801) 660-1900
------------------------------------------------------------------------
/You hear people say it's not about the money? That's bull. I'm doing it
for the money.
-- John Kruk on accepting a job hosting a TV show on Fox Sports Net/