You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Maarten Stolte <da...@crash.nu> on 2001/11/18 22:57:05 UTC

receiving XML by POST

Hello,

i'm trying to figure out how to receive an xml message/file/stream(?)
using POST, and how to be able to then send that to somewhere else
(DBI).
We're using MASON, don't know if that is information needed in this, but
i saw something about MASON picking up all posts.

Maarten





Re: receiving XML by POST

Posted by Tom Servo <to...@cnw.com>.
On Mon, 26 Nov 2001, Joshua Chamas wrote:

> Maarten Stolte wrote:
> > 
> > Hello,
> > 
> > i'm trying to figure out how to receive an xml message/file/stream(?)
> > using POST, and how to be able to then send that to somewhere else
> > (DBI).
> > We're using MASON, don't know if that is information needed in this, but
> > i saw something about MASON picking up all posts.
> 
> I believe the usual way to access POST data, $r->content, is only
> for form data.  To get XML data, try this:
> 
>   my $buf = '';
>   $r->read($buf, $ENV{CONTENT_LENGTH});
> 
> This is a general mod_perl API issue, and not necessarily specific
> to Mason, though Mason may have some other API specific to this.
> This may in fact collide with Mason form processing if there is
> any, since a mod_perl application will hang if it tries to 
> read the POST data twice.
> 

Mason generally does an automatic read of POST data, specify what form
fields you want, and it'll stuff the values into variables named the same
as the name fields in the POST data.   You should just be able to have the
XML be the value for some name/value pair, then do all your XML
parsing/DBI work on that value.



Re: receiving XML by POST

Posted by Joshua Chamas <jo...@chamas.com>.
Maarten Stolte wrote:
> 
> Hello,
> 
> i'm trying to figure out how to receive an xml message/file/stream(?)
> using POST, and how to be able to then send that to somewhere else
> (DBI).
> We're using MASON, don't know if that is information needed in this, but
> i saw something about MASON picking up all posts.

I believe the usual way to access POST data, $r->content, is only
for form data.  To get XML data, try this:

  my $buf = '';
  $r->read($buf, $ENV{CONTENT_LENGTH});

This is a general mod_perl API issue, and not necessarily specific
to Mason, though Mason may have some other API specific to this.
This may in fact collide with Mason form processing if there is
any, since a mod_perl application will hang if it tries to 
read the POST data twice.

-- Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051