NAME
CGI::XMLPost - receive XML file as an HTTP POST
SYNOPSIS
use
CGI::XMLPost;
my
$xmlpost
= CGI::XMLPost->new();
my
$xml
=
$xmlpost
->data();
# ... do something with $xml
DESCRIPTION
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.
METHODS
- new
-
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 :
- content_type
-
Returns the content type of the HTTP request.
- request_method
-
Returns the request method of the HTTP request.
- content_length
-
Returns the content length of the request.
- data
-
Returns the data as read from the body of the HTTP request.
- encoding
-
Gets or sets the encoding used in the response. The default is utf-8
- header
-
Returns a header suitable to be used in an HTTP response. The arguments are in the form of key/value pairs - valid keys are :
- response
-
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'.
- remote_address
-
Remotes the address of the remote peer if it is known.
- as_xpath
-
Returns an XML::XPath object inititialized with the received XML or a false value if XML::XPath is not present or the parse failed.
AUTHOR
Jonathan Stowe <jns@gellyfish.co.uk>
SEE ALSO
CGI
LICENSE
Please see the README file in the source distribution for the licence of this module.