stas 2003/02/12 15:42:23
Modified: lib/Apache compat.pm
. Changes
Added: t/compat conn_authen.t
t/response/TestCompat conn_authen.pm
Log:
Add Apache::compat methods: $r->connection->auth_type and
$r->connection->user (requires 'PerlOptions +GlobalRequest') + tests
Revision Changes Path
1.1 modperl-2.0/t/compat/conn_authen.t
Index: conn_authen.t
===================================================================
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestRequest;
plan tests => 1, \&have_lwp;
my $location = "/TestCompat::conn_authen";
ok GET_OK $location, username => 'dougm', password => 'foo';
1.1 modperl-2.0/t/response/TestCompat/conn_authen.pm
Index: conn_authen.pm
===================================================================
package TestCompat::conn_authen;
# simply check that we can retrieve:
# $r->connection->auth_type
# $r->connection->user
# both records don't exist in 2.0 conn_rec and therefore require
# 'PerlOptions +GlobalRequest' to retrieve those via Apache->request
use strict;
use warnings FATAL => 'all';
use Apache::TestUtil;
use Apache::Test;
use Apache::compat ();
use Apache::Constants qw(OK REMOTE_HOST);
sub handler {
my $r = shift;
my($rc, $sent_pw) = $r->get_basic_auth_pw;
return $rc if $rc != Apache::OK;
my $auth_type = $r->connection->auth_type || '';
die "auth_type is '$auth_type', should be 'Basic'"
unless $auth_type eq 'Basic';
my $user = $r->connection->user || '';
die "user is '$user', while expecting 'dougm'"
unless $user eq 'dougm';
OK;
}
1;
__DATA__
require valid-user
AuthType Basic
AuthName simple
SetHandler modperl
PerlOptions +GlobalRequest
PerlAuthenHandler TestCompat::conn_authen
PerlResponseHandler Apache::TestHandler::ok1
1.77 +7 -0 modperl-2.0/lib/Apache/compat.pm
Index: compat.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- compat.pm 31 Jan 2003 04:37:06 -0000 1.76
+++ compat.pm 12 Feb 2003 23:42:23 -0000 1.77
@@ -530,5 +530,12 @@
return Apache::DECLINED;
}
+package Apache::Connection;
+
+# auth_type and user records don't exist in 2.0 conn_rec struct
+# 'PerlOptions +GlobalRequest' is required
+sub auth_type { Apache->request->auth_type }
+sub user { Apache->request->user }
+
1;
__END__
1.124 +4 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- Changes 7 Feb 2003 02:58:30 -0000 1.123
+++ Changes 12 Feb 2003 23:42:23 -0000 1.124
@@ -10,6 +10,10 @@
=item 1.99_09-dev
+Add Apache::compat methods: $r->connection->auth_type and
+$r->connection->user (requires 'PerlOptions +GlobalRequest') + tests
+[Stas]
+
Several issues resolved with parsing headers, including making work
the handlers calling $r->content_type() and not sending raw headers,
when the headers scanning is turned on. Lots of tests added to