in reply to RE: RE: Getting username and password from the URL.
in thread Getting username and password from the URL.
You should set up your script as an Apache::Registry script. Then you can get $r like this:
To set the script up as Apache::Registry, add something like this to httpd.conf:my $r = Apache->request;
This sets up the perl subroutine under the document root to run under Apache::Registry. So put your script there.<Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI </Location>
Or, if you set up a mod_perl handler, your handler subroutine will be passed $r.
For example, you might set up a handler thusly in your httpd.conf:
And then in My::Foo:<Location /foo> SetHandler perl-script PerlHandler My::Foo </Location>
I'd recommend trying the first approach.package My::Foo; use strict; sub handler { my $r = shift; my $user = $r->connection->user; my($ret, $password) = $r->get_basic_auth_pw; $r->send_http_header; $r->print($user); $r->print($password); } 1;
|
|---|