perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dermot Paikkos" <>
Subject Re: Help with request data
Date Fri, 22 Apr 2005 14:51:56 GMT
On 22 Apr 2005 at 10:30, Geoffrey Young wrote:
> > MP2 RC5
> > 
> > I am moving from a MP1 to MP2 server and am having trouble. I have
> > opted to re-write the scripts I had so I could add some more
> > functions.
> > 
> > I am struggling tring to find methods to access my form data and
> > other headers. I am currently using
> > 
> > my $form_data = $r->the_request() 
> > 
> > and split the line from there to access the form values. 
> > 
> > For other headers I am using 
> > my $string = $r->as_string;
> > (my $user-agent) = ($string =~ /User-Agent:(.*)\sAccept/);
> > 
> ugh!  :)
> > I can get to where I want but I have the feeling I am taking the
> > long way to do it. The cook book I have on mod_perl doesn't cover
> > MP2.
> in this case everything is the same
>   use APR::Table;
>   use Apache2::RequestRec;

I got stung on this on my first attempt. I had tried


use APR::Table;

As I said, I'm not very OO literate but the error referred to 
APR::table and I hadn't loaded it. I'll load this as standard from 
now on.

>   my $ua = $r->headers_in->get('User-Agent');

This is more like what I expected :-)

> should do the trick.  $r, headers_in(), and get() are all the same in
> mp1. only the class in which they live is different.
> see the manpage for Apache2::porting for some help here - if you have
> any mp1 documentation and make the right calls, Apache2::porting will
> help tell you which classes you need to load to make it work.

Will add this though I do want to want re-write so I am hoping to get 
more familiar with a strict MP2 approach.

> > Is there no direct replacement for $r->param('field_name') or
> > $headers_in{'User-Agent'}? If not should I just continue as I am or
> > are there better methods for getting at the request?
> well, for $r->param you need libapreq2.  but $r->content or $r->args
> should be enough if you don't want to install libapreq2.

Sounds useful 

> > 
> > Apologies in advance if I have missed this in the docs but I can't
> > find anything obvious in the Request::* documentation. I also am a
> > bit OO illiterate.
> for the most part the API stemming from $r is exactly the same between
> mp1 and mp2.  there are a few exceptions, of course, but for the stuff
> you'll be using 90% of the time any source of documentation should be
> sufficient to get you started.
> see also ModPerl::MethodLookup, especially the command-line interface
> (which will help you translate a documented method into the required
> class) and preload_all_modules(), which will help get things running
> as you learn.
It certainly does thank you v. much.

> --Geoff

View raw message