You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ma...@kiritsov.com on 2007/09/28 15:51:20 UTC

set request params

as i see there is no way to set request parameter in mod_perl2
is there any chance this could happen in near future releases?


Re: set request params

Posted by Jeff Pang <rw...@gmail.com>.
2007/9/28, martin@kiritsov.com <ma...@kiritsov.com>:
> as i see there is no way to set request parameter in mod_perl2

You can rewrite an url using mp2's PerlTransHandler.
This is the sample code from book mp2 user's guide.

If the URI:
http://example.com/news/20021031/09/index.html
is now handled by:
http://example.com/perl/news.pl?date=20021031;id=09;page=index.html
the following handler can rewrite the URI in a way transparent to news.pl,
so you can still use the former URI mapping:
#file:MyApache2/RewriteURI.pm
#---------------------------
package MyApache2::RewriteURI;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(DECLINED);
sub handler {
my $r = shift;
my ($date, $id, $page) = $r->uri =~ m|^/news/(\d+)/(\d+)/(.*)|;
$r->uri("/perl/news.pl");
$r->args("date=$date;id=$id;page=$page");
return Apache2::Const::DECLINED;
}
1;

Re: set request params

Posted by Perrin Harkins <pe...@elem.com>.
On 9/28/07, martin@kiritsov.com <ma...@kiritsov.com> wrote:
> as i see there is no way to set request parameter in mod_perl2

What makes you think that?  You can set the query string in mod_perl2.
 You can also do things like create an input filter to alter
parameters on their way in.

- Perrin

RE: set request params

Posted by Adam Prime x443 <ap...@brunico.com>.
That's probably a question for the libapreq list. I know that for me
this was a really annoying thing to have to work around when porting to
MP2.  the other thing that changed in apreq is that @params =
$req->param() will now return (a, b, b)  for the query string
"?a=1&b=1&b=2" instead of  (a, b).  That mangled a few things on me.

To get around not being able to do $req->param('a' => 'something else'),
i ended up parsing the whole param structure out into a datastructure
that i could modify if i needed to, which isn't a very nice way to
handle it unfourtunately.

Adam

-----Original Message-----
From: martin@kiritsov.com [mailto:martin@kiritsov.com] 
Sent: Friday, September 28, 2007 9:51 AM
To: modperl@perl.apache.org
Subject: set request params

as i see there is no way to set request parameter in mod_perl2
is there any chance this could happen in near future releases?