Dermot Paikkos wrote: > Hi > > 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; my $ua = $r->headers_in->get('User-Agent'); 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. > > 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. > > 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. HTH --Geoff