Mark Lawrence > NCGI-0.12 > NCGI::Response

Download:
NCGI-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.12   Source  

NAME ^

NCGI::Response - Represent A CGI Response

SYNOPSIS ^

  use NCGI::Response;
  my $r = NCGI::Response->new();

  my $h = $r->header;
  $h->custom_header('value');

  my $x = $r->xhtml;
  $x->_encoding('ISO-8859-1');
  $x->_goto('head');
  $x->_set_lang('en');
  $x->title('A Simple Example');

  print $r->as_string();

  # Content-Length: 302
  # Content-Type: application/xhtml+xml; charset=ISO-8859-1
  # Custom-Header: value
  # Content-Language: en
  #
  # <?xml version="1.0" encoding="ISO-8859-1" ?>
  # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  #     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  # <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  # <head>
  #     <title>A Simple Example</title>
  # </head>
  # <body></body>
  # </html>

DESCRIPTION ^

NCGI::Response represents a reply to a HTTP request. It is basically a container for an NCGI::Response::Header object and an XML::API object.

Some headers such as Content-Type, Content-Language are automatically derived from the content object when as_string is called.

NCGI::Response objects are usually created and accessed through the NCGI 'header' function.

METHODS ^

new

Create a new NCGI::Response object. An NCGI::Header object is automatically instantiated, but none of the content objects exist yet.

header

Returns the NCGI::Header object.

xhtml

Returns a reference to an XML::API::XHTML object, creating it on the first call. Sets an internal content pointer so that this object is the one used to generate content by the as_string() method.

rss

Returns a reference to an XML::API::RSS object, creating it on the first call. Sets an internal content pointer so that this object is the one used to generate content by the as_string() method.

Not implemented yet.

text

Returns a reference to an XML::API::TEXT object, creating it on the first call. Sets an internal content pointer so that this object is the one used to generate content by the as_string() method.

Not implemented yet.

content

Compatibility function. Returns xhtml().

as_string

Returns the header and the content as a string suitable for sending directly to the browser. The content used depends on the last xhtml() or rss() or text() call.

fast_string

Returns the header and the content as a string suitable for sending directly to the browser. Uses the XML::API _fast_string method of generating the content.

SEE ALSO ^

CGI::Simple, NCGI, NCGI::Response::Header XML::API

AUTHOR ^

Mark Lawrence <nomad@null.net>

Feel free to send me a mail telling me if you have used this module. Until now I'm the only known user...

COPYRIGHT AND LICENSE ^

Copyright (C) 2005-2007 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.