httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lewis <>
Subject Re: Probably OT. Difficulty implementing content handler Apache2
Date Thu, 09 Jul 2009 17:15:53 GMT
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
> or
> 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...
> 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 :


LoadModule perl_module modules/
PerlResponseHandler Apache2::example
SetHandler modperl

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%) {
Hello from <B>this</B>!

    return Apache2::Const::OK;
  return Apache2::Const::DECLINED;


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.  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 Lewis
Chief Nerd 	SILVERHAWK <> 	(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/

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message