tags:

views:

241

answers:

1

I'm trying to write a Perl CGI script to handle XML-RPC requests, in which an XML document is sent as the body of an HTTP POST request.

The CGI.pm module does a great job at extracting named params from an HTTP request, but I can't figure out how to make it give me the entire HTTP request body (i.e. the XML document in the XML-RPC request I'm handling).

If not CGI.pm, is there another module that would be able to parse this information out of the request? I'd prefer not to have to extract this information "by hand" from the environment variables. Thanks for any help.

+8  A: 

You can get the raw POST data by using the special parameter name POSTDATA.

my $q = CGI->new;
my $xml = $q->param( 'POSTDATA' );

Alternatively, you could read STDIN directly instead of using CGI.pm, but then you lose all the other useful stuff that CGI.pm does.

The POSTDATA trick is documented in the excellent CGI.pm docs here.

friedo
Thanks! Sorry I missed that in the docs.
Ryan Tate