NAME

CGI::Lite::Request - Request object based on CGI::Lite

SYNOPSIS

use CGI::Lite::Request;
 
my $req = CGI::Lite::Request->new;
my $req = CGI::Lite::Request->instance;
 
$foo  = $req->param('foo');
@foos = $req->param('foo');                   # multiple values
@params = $req->params();                     # params in parse order
$foo  = $req->args->{foo};                    # hash ref
%args = $req->args;                           # hash
$uri = $req->uri;                             # $ENV{SCRIPT_NAME}/$ENV{PATH_INFO}
$req->print(@out);                            # print to STDOUT
$req->headers;                                # HTTP::Headers instance
$req->send_http_header;                       # print the header
$req->send_cgi_header(@fields};               # prints a raw header
$req->content_type('text/html');              # set
$req->content_type;                           # get
$path = $req->path_info;                      # $ENV{PATH_INFO}
$cookie = $req->cookie('my_cookie');          # fetch or create a cookie
$req->cookie('SID')->value($sessid);          # set a cookie
$upload = $req->upload('my_field');           # CGI::Lite::Upload instance
$uploads = $req->uploads;                     # hash ref of CGI::Lite::Upload objects

DESCRIPTION

This module extends CGI::Lite to provide an interface which is compatible with the most commonly used methods of Apache::Request as a fat free alternative to CGI. All methods of CGI::Lite are inherited as is, and the following are defined herein:

METHODS

instance

Allows CGI::Lite::Request to behave as a singleton.

new

Constructor

headers

accessor to an internally kept HTTP::Headers object.

parse

parses the incoming request - this is called automatically from the constructor, so you shouldn't need to call this expicitly.

args

return the request parameters as a hash or hash reference depending on the context. All form data, query string and cookie parameters are available in the returned hash(ref)

param( $key )

get a named parameter. If called in a scalar context, and if more than one value exists for a field name in the incoming form data, then an array reference is returned, otherwise for multiple values, if called in a list context, then an array is returned. If the value is a simple scalar, then in a scalar context just that value is returned.

params

returns all the parameters in the order in which they were parsed. Also includes cookies and query string parameters.

uri

returns the url minus the query string

secure

returns true if the request came over https

path_info

accessor to the part of the url after the script name

print

print to respond to the request. This is normally done after send_http_header to print the body of data which should be sent back the the user agent

send_http_header

combines the response headers and sends these to the user agent

returnes a named CGI::Lite::Cookie object. If one doesn't exist by the passed name, then creates a new one and returns it. Typical semantics would be:

$sessid = $req->cookie('SID')->value;
$req->cookie('SID')->value($sessid);

both of these methods will create a new CGI::Lite::Cookie object if one named 'SID' doesn't already exist. If you don't want this behaviour, see cookies method

cookies

returns a hash reference of CGI::Lite::Cookie objects keyed on their names. This can be used for accessing cookies where you don't want them to be created automatically if they don't exists, or for simply checking for their existence:

if (exists $req->cookies->{'SID'}) {
    $sessid = $req->cookies->{'SID'}->value;
}

see CGI::Lite::Cookie for more details

upload

returns a named CGI::Lite::Upload object keyed on the field name with which it was associated when uploaded.

uploads

returns a hash reference of all the CGI::Lite::Upload objects keyed on their names.

see CGI::Lite::Upload for details

AUTHOR

Richard Hundt <richard NO SPAM AT protea-systems.com>

SEE ALSO

CGI::Lite, CGI::Lite::Cookie, CGI::Lite::Upload

LICENCE

This library is free software and may be used under the same terms as Perl itself

1 POD Error

The following errors were encountered while parsing the POD:

Around line 381:

You forgot a '=back' before '=head1'