CGI::XMLPost - receive XML file as an HTTP POST
use CGI::XMLPost; my $xmlpost = CGI::XMLPost->new(); my $xml = $xmlpost->data(); # ... do something with $xml
CGI::XMLPost is a lightweight module for receiving XML documents in the body of an HTTP request. It provides some utility methods that make it easier to work in a CGI environment without requiring any further modules.
This is the constructor of the class. If it succeeds in reading the POST data correct it will return a a blessed object - otherwise undef.
The arguments are in the form of a hash reference - the keys are :
If this is set to a true value then the HTTP request method and content type are checked. If the first is not POST and the second does not match 'xml$' then the method will return undef.
Returns the content type of the HTTP request.
Returns the request method of the HTTP request.
Returns the content length of the request.
Returns the data as read from the body of the HTTP request.
Gets or sets the encoding used in the response. The default is utf-8
Returns a header suitable to be used in an HTTP response. The arguments are in the form of key/value pairs - valid keys are :
The HTTP status code to be returned - the default is 200 (OK).
The content type of the response - the default is 'application/xml'.
Returns a string that is suitable to be sent in the body of the response. The default is to return an XML string of the form :
<?xml version="1.0" encoding="iso-8859-1"?> <Response> <Code>$status</Code> <Text>$text</Text> </Response>
Where $status is the status code used in the header as described above and $text is the desciptive text for that status. If a different text is required this can be supplied with the argument key 'text'.
Remotes the address of the remote peer if it is known.
Returns an XML::XPath object inititialized with the received XML or a false value if XML::XPath is not present or the parse failed.
Jonathan Stowe <jns@gellyfish.com>
CGI
Please see the README file in the source distribution for the licence of this module.
To install CGI::XMLPost, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::XMLPost
CPAN shell
perl -MCPAN -e shell install CGI::XMLPost
For more information on module installation, please visit the detailed CPAN module installation guide.