geektron has asked for the wisdom of the Perl Monks concerning the following question:

This looks like a simple error to debug and solve, but I can't see in the actual code what the issue is ... The Error:
[Thu Mar 4 16:55:00 2004] [error] auth_type TestCookie::AuthCookieHan +dler [Thu Mar 4 16:55:00 2004] [error] auth_name TestCookie [Thu Mar 4 16:55:00 2004] [error] ses_key_cookie [Thu Mar 4 16:55:00 2004] [error] uri /protected/ Can't locate object method "request" via package "Apache" at /home/htt +pd/htdocs/login.cgi line 5.
Looks all normal, since "can't find method foo" errors usually mean a package isn't used. but in my httpd.conf:
<Perl> use lib qw# /home/httpd/htdocs/libs #; </Perl> + + PerlModule Apache::AuthCookie PerlModule TestCookie::AuthCookieHandler PerlSetVar TestCookiePath / PerlSetVar TestCookieLoginScript /login.cgi PerlSetVar AuthCookieDebug 3 + + # These documents require user to be logged in. <Location /protected> AuthType TestCookie::AuthCookieHandler AuthName TestCookie PerlAuthenHandler TestCookie::AuthCookieHandler->authenticate PerlAuthzHandler TestCookie::AuthCookieHandler->authorize Require user programmer </Location> + + + + #this is the action of the login.pl script above. <Files LOGIN> AuthType TestCookie::AuthCookieHandler AuthName TestCookie SetHandler perl-script PerlHandler TestCookie::AuthCookieHandler->login </Files> <Location /perl-status> SetHandler perl-script PerlHandler Apache::Status </Location>
I'm using the sample config to make sure I can get things configured correctly. TestCookie::AuthCookieHandler gets called, and it looks like this:
package TestCookie::AuthCookieHandler; use strict; use Apache; use Apache::Constants qw(:common); use Apache::AuthCookie; use vars qw($VERSION @ISA); + + $VERSION = substr(q$Revision: 1.2 $, 10); @ISA = qw(Apache::AuthCookie);
( it's just Sample::AuthCookieHandler from the distro renamed and moved. )

so, i'm including the Apache module, and I have this as my server setup:

Server Version: Apache/1.3.27 (Unix) Resin/2.1.11 PHP/4.3.1 mod_perl/1 +.27
so i have a mod_perl enabled server, Apache::AuthCookie installed ... everything *should* work ... but it doesn't, and i'm lost ... any pointers?

Replies are listed 'Best First'.
Re: Apache::AuthCookie woes
by perrin (Chancellor) on Mar 05, 2004 at 22:00 UTC
    This probably means you don't have login.cgi configured to run under mod_perl and it's being run under mod_cgi instead.
Re: Apache::AuthCookie woes
by Prior Nacre V (Hermit) on Mar 06, 2004 at 20:01 UTC

    I can't see Apache::Registry listed anywhere in your post. That will be why it can't find the request() method. Apache::Registry has details of adding this to your httpd.conf file.

    Depending on your setup, you may need to add use Apache::Registry to login.cgi or some module it calls.

    I usually like to keep my options open with something like:

    use Apache::Registry; my $r; eval { $r = Apache->request }; if (defined $r) { $r->content_type(...); ... $r->send_http_header; } else { print "Content-Type: ... \n"; ... print "\n"; }

    That way your CGI script will work under both mod_cgi and mod_perl without modification.

    PN5

      yes, i was thinking about that after the first reply, that i don't remember if a  <PerlHandler> is set up on that machine. That's what I'm going to check first. I just started mucking in that  httpd.conf ... it's a workstation with a bunch of old crap left on it.