The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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 :

strict

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.

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.

Returns a header suitable to be used in an HTTP response. The arguments are in the form of key/value pairs - valid keys are :

status

The HTTP status code to be returned - the default is 200 (OK).

type

The content type of the response - the default is 'application/xml'.

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" 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.com>

SEE ALSO

CGI

LICENSE

Please see the README file in the source distribution for the licence of this module.