the subclassing mechanism for Apache::Request (and Apache) looks for an
`r' or `_r' key if the object is a hash reference. problem is the value
of that key may also be a hash reference with an `r' or `_r' inside of it,
for example:
package One;
use Apache::Request ();
@ISA = qw(Apache::Request);
sub new {
my($class, $r) = @_;
bless { r => Two->new($r) }, $class;
}
package Two;
@ISA = qw(One);
sub new {
my($class, $r) = @_;
bless { r => Apache::Request->new($r) }, $class;
}
my $r = One->new(shift);
$r->send_http_header;
print 'q=', $r->param('q');
patch below fixes, i'll go ahead and commit unless anybody sees a problem
with it.
Index: Request/Request.xs
===================================================================
RCS file: /home/cvs/httpd-apreq/Request/Request.xs,v
retrieving revision 1.5
diff -u -r1.5 Request.xs
--- Request/Request.xs 2001/01/03 03:58:54 1.5
+++ Request/Request.xs 2001/01/05 05:29:24
@@ -41,14 +41,16 @@
static ApacheRequest *sv_2apreq(SV *sv)
{
if (SvROK(sv) && sv_derived_from(sv, "Apache::Request")) {
- SV *obj;
+ SV *obj = sv;
- switch (SvTYPE(SvRV(sv))) {
+ switch (SvTYPE(SvRV(obj))) {
case SVt_PVHV :
- obj = r_key_sv(sv);
+ do {
+ obj = r_key_sv(obj);
+ } while (SvROK(obj) && (SvTYPE(SvRV(obj)) == SVt_PVHV));
break;
default:
- obj = sv;
+ break;
};
return (ApacheRequest *)SvIV((SV*)SvRV(obj));
}