logo       

Re: Getting at content :o(: msg#00174

web.mason.user

Subject: Re: Getting at content :o(

On Wed, 20 Aug 2003, Gareth Kirwan wrote:
> I'm generating a request with:
> my $ua = LWP::UserAgent->new();
> $ua->agent('InsLink/$Revision: 1.25 $ ' . $ua->agent);
> $ua->timeout( 20 ) if defined( 20);
>
> my $request = HTTP::Request->new( POST =>
> 'http://devel.e-travelsure.com/xml/Inslink.xml' );
> $request->content_type('application/xml');
> $request->content( $m->scomp('InitialRequest-xml.mc') );
>
> my $response = $ua->request($request);
>
> My question is: How does Inslink.xml get at what I would have expected to
> have been $r->content ?

Since $r->content will return an XML document instead of an
x-www-form-urlencoded document, CGI or Apache::Request will probably not
know what to do with it. And since you can only call $r->content once,
you are going to have to get to it before they do.

I suggest writing a handler which will intercept the content before mason
does. Something like this might work:

use HTML::Mason::ApacheHandler;

my $ah = HTML::Mason::ApacheHandler->new (
..name/value params..
allow_globals => qw( $xml_content ),
);
...
sub handler {
my $r = shift;

# grab xml content before the request does.
undef $HTML::Mason::Commands::xml_content;
if ($r->uri =~ m/\.xml$/) {
$HTML::Mason::Commands::xml_content = $r->content;
}

$ah->handle_request($r);
}

(Maybe we should allow user-defined classes for args_method, instead of
only CGI and "mod_perl".)

~ John Williams




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise