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

NCGI::Response::Header - HTTP Header object for NCGI

SYNOPSIS

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

  $header->content_type('text/plain');
  $header->status('200 OK');
  $header->test_header('tested');
  $header->_add_multi('1');
  $header->_add_multi('2');
  $header->_send();

  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::Response::Header provides a simple HTTP Header object for responding to CGI requests.

METHODS

new

Returns a new NCGI::Response::Header object.

location

Adds a 'Location:' header, making sure that there is no 'Status:' header as well.

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.

_send

Print the HTTP header to STDOUT. Exactly the same as 'print $header->_as_string;' except that _send keeps track if it has already been called and will croak if called more than once.

SEE ALSO

NCGI

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright (C) 2005-2008 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.