You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Greg Balmer <Gr...@Mapflow.com> on 2004/04/07 10:49:07 UTC

[mp2] Using MP2 to rewrite URLs based on POST Body data

Hi all,

I have been looking into various ways to achieve a goal of rewriting
incomming url's based on the Content of a particular request's POST body.
Basically our service has a single access point http://ourhost.com/Service
and I want to be able to examine the POSTed (XML) content of requests
for keywords in the body and rewrite the incomming url as follows -

Request BODY :  "..............keyword1.............." then rewrite the URL
to  http://ourhost.com/Service-method1
Request BODY :  "..............keyword2.............." then rewrite the URL
to  http://ourhost.com/Service-method2
...

Why?  you may ask.  Well because we have many existing clients accessing
this single url, we would like to
distribute load... across various resources  (also configured within apache
under <location> directives,  JkMounts -> tomcat, WLBridge Mounts to
Weblogic...)
This would then give me fine grained control over the individual resources
(security, load managment...) whilst still maintaining a sigle accesspoint
for
the outside world.

I'm a bit of a newbie to this stuff, but I think this may be achievable with
InputFilters, so I was really looking for any pointers that anyone could
give.

Any help would be greatly appreciated,

Many Thanks,

Greg.

Ps.
* I have tried HTTP redirects as an alternative approach but HTTP1.1
prohibits auto re-directs for POST requests.

* I have also tried to handle this request seperation at a servlet container
level but I cannot get fine grained
control of the thread processing model (in TC or Weblogic), additionally
this approach can lead to issues where
the core HTTPServletRequest/Response objects are not guaranteed to be
threadsafe (as per the Servlet API spec...)
Greg Balmer

Mapflow
4 Merrion Square
Dublin 2
IRELAND


Tel: +353-1-6341430
Fax: +353-1-6760504
E-mail: Greg.Balmer@Mapflow.com

Check out the most recent developments on our web-site:

http://www.mapflow.com

"The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this email by
anyone else is unauthorised. If you are not the intended recipient, any
disclosure, copyright, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful"



Re: [mp2] Using MP2 to rewrite URLs based on POST Body data

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Greg Balmer" <Gr...@Mapflow.com> writes:

[...]

> Basically our service has a single access point
> http://ourhost.com/Service and I want to be able to examine the POSTed
> (XML) content of requests for keywords in the body and rewrite the
> incomming url as follows - 
> 
> Request BODY :  "..............keyword1.............." then rewrite the URL
> to  http://ourhost.com/Service-method1
> Request BODY :  "..............keyword2.............." then rewrite the URL
> to  http://ourhost.com/Service-method2
> ...

If there was an xml parser available for libapreq2, you could use
Apache::Request to do this without any worries.

[...]

> I'm a bit of a newbie to this stuff, but I think this may be
> achievable with InputFilters, so I was really looking for any pointers
> that anyone could give.

It is, but you need to be very careful about spooling the post data for
the redirected url.  This is basically what mod_apreq.c does in 
libapreq2, but it's pretty tricky.  Perhaps convincing apreq-dev@ 
to support xml would be your best bet.

-- 
Joe Schaefer


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html