in reply to Apache::FakeRequest request object?

I think that you can emulate only methods listed inside Apache::FakeRequest and there isn't a method r; in other words, r is not a method of Apache request. Can you show us some more code? Is it a Apache::Registry script or a plain handler?

Ciao, Valerio

Replies are listed 'Best First'.
Re: Re: Apache::FakeRequest request object?
by creeble (Sexton) on Feb 03, 2004 at 02:43 UTC
    I get that r isn't a method of Apache::FakeRequest, I'm trying to make it one somehow. It's a regular PerlHandler that I'm testing, and the first thing that the handler does is assign $self->r to something, which is normally where the HTTP::Request (or Apache::request, I guess) object lives. I'm most confused -- every handler I've ever seen accesses the 'r' (request) method, but Apache::FakeRequest doesn't have one. How can it get one? Creeble

      I'm sorry, but I can't remember any r method of Apache requests... would you be so kind to show me some code? For example, a simple (and stupid) handler would be like the following:

      package myHandler; use Apache::Constants qw(:common); sub handler { my $r = shift; warn "request is ", $r->as_string, "\n"; return DECLINED; }
      In this code $r will contain the Apache request object and, as you can see in Apache request man page, there is no r method...

      Ciao, Valerio

        Sorry, I'm a dope. The 'r' method is something that happens in *my* code (or in my code's super class, anyway). All I need to do is set the uri and filename of the FakeRequest method, then call the right handler:
        use HTTP::Request; use Apache::FakeRequest; use Apache::MP3::Urlwitzer; my $request = Apache::FakeRequest->new('get_remote_host'=>'foobar. +com'); $request->uri('/Music'); Apache::MP3::handler('Apache::MP3::Urlwitzer', $request);
        My super class's new() methods set 'r' to the request. Thanks for the help, sorry for the confusion. Creeble