NAME
NCGI::Header - HTTP Header object for NCGI
SYNOPSIS
use NCGI::Header;
my $header = NCGI::Header->instance();
$header->content_type('text/plain');
$header->status('200 OK');
$header->test_header('tested');
$header->_add_multi('1');
$header->_add_multi('2');
$header->_print();
print "The header sent was:\n\n",$header->_as_string();
# The header sent was:
#
# Content-Type: text/plain
# Status: 200 OK
# Multi: 1
# Multi: 2
# Test-Header: tested
DESCRIPTION
NCGI::Header provides a simple HTTP Header object for responding to CGI requests. It is a singleton object (see Class::Singleton on CPAN for a description of what this means).
METHODS
instance()
Returns a reference to the NCGI::Header object, creating it if necessary. The newly created object has a single header 'Content-Type' set to 'text/html'.
header_type()
Create/Set the header 'Header-Type'. Notice that underlines are converted to dashes and that the first character of words are uppercased. This is an AUTOLOAD function meaning you can create whatever headers you like. If there were previously multiple 'Header-Type' headers then they are all replaced by the value of this call.
There is no validity checking when setting so you should read the HTTP/MIME specifications for valid strings.
_add_header_type()
Add a header 'Header-Type'. This can be called multiple times and multiple headers will be sent. Notice the automatic formatting as is done for header_type.
_as_string()
Returns a string representation of the HTTP Header.
_print()
Print the HTTP header to STDOUT. Exactly the same as 'print $header->_as_string;' except that _print will warn if it is called more than once.
SEE ALSO
AUTHOR
Mark Lawrence <nomad@null.net>
COPYRIGHT AND LICENSE
Copyright (C) 2005 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.