You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Seldo <ne...@seldo.com> on 2003/02/17 04:45:54 UTC
Semi-complicated question: modifying the content of a request before passing to CGI?
Okay, so here's what I need to do:
1. Receive a request to a given URI, X
2. Based on that URI, change certain values with the request
(e.g. change the names or values of variables posted by the user,
modify the "x-www-form-urlencoded" data, whatever...)
3. Translate the URI to a new URI (one of a number of CGI programs)
4. Execute that CGI (such that the CGI runs in an environment with
variables and posted data modified as per step 2 )
I'm running mod_perl 2.0 with Apache 2.0.x, and the documentation of
these sorts of features:
http://perl.apache.org/docs/2.0/api/Apache/RequestUtil.html
...is sort of incomplete. Whoopsie. My fault for being all
bleeding-edge, right? Here's what I've got so far:
1. Can do. I can write a PerlTransHandler that catches the URI
2. Don't know how to do. The 1.0 documentation mentions the
header_in() method which can apparently set headers in the request
as well as get them. I can't find this method in the 2.0
documentation, does it or an equivalent exist? And is there anything
similar for the PUT/POST type data?
3. Can do. This bit is no problem.
4. Don't know how to do. How do you tell the server to execute a
file using CGI protocol? Is this even possible?
The above method, assuming it's possible to do the two things I asked
about, will work fine. If it doesn't work, then I'll be forced to make
my PerlTransHandler re-implement CGI, which isn't *that* hard but
sounds like a fairly stupid idea when the server does it already. But
even in the case, I need to know how to set "environment variables"
for CGI on a per-execution basis.
Any help greatly appreciated, this project is now due in a week and
I'm beginning to feel great big stormclouds of doom closing in :-)
Seldo.
P.S. I only recently noticed that Stas, who helped me out with my last
question, is listed as the author/maintainer of the 2.0 documentation.
Cool! :-)
____________________________________________
Seldo Voss: www.seldo.com
ICQ #1172379 or me@seldo.com
--------------------------------------------
Bart's Blackboard: "I will not eat things for money."
Re: Semi-complicated question: modifying the content of a request
before passing to CGI?
Posted by Stas Bekman <st...@stason.org>.
Seldo wrote:
> Okay, so here's what I need to do:
> 1. Receive a request to a given URI, X
>
> 2. Based on that URI, change certain values with the request
> (e.g. change the names or values of variables posted by the user,
> modify the "x-www-form-urlencoded" data, whatever...)
>
> 3. Translate the URI to a new URI (one of a number of CGI programs)
>
> 4. Execute that CGI (such that the CGI runs in an environment with
> variables and posted data modified as per step 2 )
>
> I'm running mod_perl 2.0 with Apache 2.0.x, and the documentation of
> these sorts of features:
>
> http://perl.apache.org/docs/2.0/api/Apache/RequestUtil.html
>
> ...is sort of incomplete. Whoopsie.
We have very few hands, so coding is of a higher priority. Most of the API
docs from 1.0 apply to 2.0. Almost all differrences are documented here:
http://perl.apache.org/docs/2.0/user/compat/compat.html
If something is missing, please post patches.
Help with 2.0 docs is very welcome.
> My fault for being all
> bleeding-edge, right? Here's what I've got so far:
>
> 1. Can do. I can write a PerlTransHandler that catches the URI
>
> 2. Don't know how to do. The 1.0 documentation mentions the
> header_in() method which can apparently set headers in the request
> as well as get them. I can't find this method in the 2.0
> documentation, does it or an equivalent exist?
http://perl.apache.org/docs/2.0/user/compat/compat.html#C__r_E_gt_header_in_
> And is there anything
> similar for the PUT/POST type data?
what do you mean? check the above URL.
> 3. Can do. This bit is no problem.
>
> 4. Don't know how to do. How do you tell the server to execute a
> file using CGI protocol? Is this even possible?
You don't need to do anything. Just configure your mod_cgi as usual, and once
you've changed $r->filename to point to the location of cgi, Apache will take
care of it. (I assume that you want the cgis to be run by mod_cgi, not mod_perl)
> The above method, assuming it's possible to do the two things I asked
> about, will work fine. If it doesn't work, then I'll be forced to make
> my PerlTransHandler re-implement CGI, which isn't *that* hard but
> sounds like a fairly stupid idea when the server does it already. But
> even in the case, I need to know how to set "environment variables"
> for CGI on a per-execution basis.
>
> Any help greatly appreciated, this project is now due in a week and
> I'm beginning to feel great big stormclouds of doom closing in :-)
Your task is pretty trivial, so you should be fine.
> Seldo.
>
> P.S. I only recently noticed that Stas, who helped me out with my last
> question, is listed as the author/maintainer of the 2.0 documentation.
> Cool! :-)
Hopefully this will change asap and other people will take over varous documents.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com