NAME

PSP::CGI::HTTP - exportable functions for generating HTTP status pages.


SYNOPSIS

  use PSP::CGI::HTTP;
  my $success;
  $success = PSP::CGI::HTTP::redirect($psp,$url,$code);
  $success = PSP::CGI::HTTP::notFound($psp,$url);
  $success = PSP::CGI::HTTP::status($psp,$url,$code,$codeName,$message,%extraHeaders);
  
  use PSP::CGI::HTTP qw(redirect notFound status);
  my $success;
  $success = redirect($psp,$url,$code);
  $success = notFound($psp,$url);
  $success = status($psp,$code,$codeName,$message,%extraHeaders);


DESCRIPTION

This module provides exportable functions that create HTTP status pages commonly used in CGI programs i.e. for redirecting the browser to another URL, telling the browser about missing files, etc.. This module was created as a companion to the Perl Script Pages Engine. See the PSP::Engine manpage for more information.


OVERVIEW

Exportable Functions

redirect
Creates a HTTP redirect (``Moved'') message, redirecting the web browser to another URL. See redirect function for details.

notFound
Creates a HTTP 404 (``Not Found'') message, telling the web browser the requested URL does not exist. See notFound function for details.

status
Creates a user defined HTTP status message. See status function for details.


SYNTAX

redirect Function

Creates a HTTP redirect (``Moved'') message, redirecting the web browser to another URL.

  use PSP::CGI::HTTP;
  my $success = PSP::CGI::HTTP::redirect($psp,$url,$code);
  
  use PSP::CGI::HTTP qw(redirect);
  my $success = redirect($psp,$url,$code);

Former content of the PSP output queue and CGI headers are flushed.

This function can be exported.

Required Parameters

$psp
The PSP::Engine object to flush and push the message to. See the PSP::Engine manpage for details.

$url
Text string describing the URL to redirect the web browser to. Note that this variable is not sanitized for HTTP header output by this function.

Optional Parameters

$code
HTTP status code to use. Might be either 301 (``Moved Permanently'') or 302 (``Moved Temporarily''). By default, 302 (``Moved Temporarily'') is used.

Return Values

$success
Returns 1 on success or undef on error. An undef value also means the PSP output queue and CGI HTTP headers were NOT flushed.

notFound Function

Creates a HTTP 404 (``Not Found'') message, telling the web browser the requested URL does not exist.

  use PSP::CGI::HTTP;
  my $success = PSP::CGI::HTTP::notFound($psp,$url);
  
  use PSP::CGI::HTTP qw(notFound);
  my $success = notFound($psp,$url);

Former content of the PSP output queue and CGI headers are flushed.

This function can be exported.

Required Parameters

$psp
The PSP::Engine object to flush and push the message to. See the PSP::Engine manpage for details.

$url
Text string describing the URL that was not found.

Optional Parameters

None.

Return Values

$success
Returns 1 on success or undef on error. An undef value also means the PSP output queue and CGI HTTP headers were NOT flushed.

status Function

Creates a user defined HTTP status message.

  use PSP::CGI::HTTP;
  my $success = PSP::CGI::HTTP::status($psp,$url,$code,$codeName,$message,%extraHeaders);
  
  use PSP::CGI::HTTP qw(status);
  my $success = status($psp,$code,$codeName,$message,%extraHeaders);

Former content of the PSP output queue and CGI headers are flushed.

This function can be exported.

Required Parameters

$psp
The PSP::Engine object to flush and push the message to. See the PSP::Engine manpage for details.

$codeName
``Name'' of the status, i.e. ``Not Found'' for code 404.

$message
The HTML message to show to the user, describing the status.

Optional Parameters

%extraHeaders
A hash containing additional headers to send to the client.

Return Values

$success
Returns 1 on success or undef on error. An undef value also means the PSP output queue and CGI HTTP headers were NOT flushed.


AUTHOR

Veit Wahlich

E-Mail: cru |at| zodia |dot| de

WWW: http://home.ircnet.de/cru/


VERSION

v0.7 Wednesday, 18 January 2006


COPYRIGHT/LICENSE

Copyright 2004-2006 Veit Wahlich

This software is distributed as free (libre) software under the terms of the GNU General Public License, version 2 <http://www.gnu.org/copyleft/gpl.html>. The author disclaims responsibility of any damage or harm caused directly or indirectly by usage of this software. Use only at your own risk.