You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dermot Paikkos <de...@sciencephoto.co.uk> on 2005/04/22 16:13:51 UTC
Help with request data
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/);
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.
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?
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.
Thanx.
Dp.
Re: Help with request data
Posted by Dermot Paikkos <de...@sciencephoto.co.uk>.
On 22 Apr 2005 at 18:36, Markus Wichitill wrote:
>
> At the moment you'll have to pull the current version of apreq2 from
> SVN for MP2-RC5.
>
> http://svn.apache.org/repos/asf/httpd/apreq/trunk
thanx but I think I might be getting out of my depth. I'll wait till
there's a full release.
Dp.
Re: Help with request data
Posted by Markus Wichitill <ma...@gmx.de>.
Dermot Paikkos wrote:
> I just tried to install libapreq2 (v2-2.03-dev) from CPAN. It was a
> bit of a saga. I was missing a couple of prerequisites. Then it
> couldn't find Apache2.pm - I made a link to sort that - then I ran
> make test and there were errors. At that point I halted.
At the moment you'll have to pull the current version of apreq2 from SVN for
MP2-RC5.
http://svn.apache.org/repos/asf/httpd/apreq/trunk
Re: Help with request data
Posted by Dermot Paikkos <de...@sciencephoto.co.uk>.
On 23 Apr 2005 at 0:25, JH Foo wrote:
> Hello Dermot,
Hi,
> You need to use Apache2::Request for mp2. This comes with the
> libapreq2 package from the excellent theoryx5 site. Notice the change
> in the package namespace.
I just tried to install libapreq2 (v2-2.03-dev) from CPAN. It was a
bit of a saga. I was missing a couple of prerequisites. Then it
couldn't find Apache2.pm - I made a link to sort that - then I ran
make test and there were errors. At that point I halted. There where
numerous errors in the log:
[Fri Apr 22 16:29:08 2005] [debug] mod_apreq.c(455): [client
127.0.0.1] removing filter (1)
[Fri Apr 22 16:29:08 2005] [error] [client 127.0.0.1]
[test_cgi.c(51): Success] Creating apreq_request
[Fri Apr 22 16:29:08 2005] [error] [client 127.0.0.1]
[apreq_env.c(182): Success] Lookup of CONTENT_TYPE failed: status=2
[Fri Apr 22 16:29:08 2005] [error] [client 127.0.0.1]
[test_cgi.c(55): Success] Fetching the parameters [Fri Apr 22
16:29:08 2005] [error] [client 127.0.0.1] [apreq_env.c(182): Success]
Lookup of CONTENT_TYPE failed: status=2
[Fri Apr 22 16:29:08 2005] [error] [client 127.0.0.1]
[test_cgi.c(107): Success] Fetching all parameters [Fri Apr 22
16:29:08 2005] [error] [client 127.0.0.1] [test_cgi.c(51): Success]
Creating apreq_request
[Fri Apr 22 16:29:08 2005] [error] [client 127.0.0.1]
[apreq_env.c(182): Success] Lookup of CONTENT_TYPE failed: status=2
I can probably get by without libapreq2 and use the $r-the_request();
for now.
Cheers.
Dp.
> > 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/);
> >
> > 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.
> >
> > 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?
> >
> > 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.
> >
> > Thanx.
> > Dp.
> >
> >
> >
> >
>
>
~~
Dermot Paikkos * dermot@sciencephoto.com
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668
Re: Help with request data
Posted by JH Foo <jh...@nexlabs.com>.
Hello Dermot,
You need to use Apache2::Request for mp2. This comes with the libapreq2
package from the excellent theoryx5 site. Notice the change in the package
namespace.
----- Original Message -----
From: "Dermot Paikkos" <de...@sciencephoto.co.uk>
To: <mo...@perl.apache.org>
Sent: Friday, April 22, 2005 10:13 PM
Subject: Help with request data
> 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/);
>
> 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.
>
> 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?
>
> 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.
>
> Thanx.
> Dp.
>
>
>
>
Re: Help with request data
Posted by Dermot Paikkos <de...@sciencephoto.co.uk>.
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
$agent->$r-headers_in->{'User-Agent'}
without
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.
>
> HTH
It certainly does thank you v. much.
Dp.
> --Geoff
>
Re: Help with request data
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
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