Re: Probably OT. Difficulty implementing content handler Apache2
Joe Lewis wrote: . . . . 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); HTMLBODY H3Hello/H3 Hello from Bthis/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. After being distracted by other tasks, I have returned to this, done everything carefully, and now can proceed to debug the actual handler part. Thanks! Bernard Higonnet PS I have left a copy of your helpful code for anyone coming upon it in a search.
Re: Probably OT. Difficulty implementing content handler Apache2
Check for segmentation faults in global error-log. -- Marko Kevac Gilda Radner - Adopted kids are such a pain - you have to teach them how to look like you. - http://www.brainyquote.com/quotes/authors/g/gilda_radner.html
Re: Probably OT. Difficulty implementing content handler Apache2
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); HTMLBODY H3Hello/H3 Hello from Bthis/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
Probably OT. Difficulty implementing content handler Apache2
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. 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
Re: Probably OT. Difficulty implementing content handler Apache2
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); HTMLBODY H3Hello/H3 Hello from Bthis/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/