NAME

NCGI::Query - HTTP GET/POST Query/Request object for NCGI

SYNOPSIS

use NCGI::Query;
my $q = NCGI::Query->instance();

print "Content-Type: text/plain\n\n";
if ($q->isquery) {
  print "GET\n" if $q->isget();
  print "POST\n" if $q->isget();
  print "Your submit button is called: ", $q->param('submit');
  print "Your submitted name as: ", $q->params->{'name'};
}
else {
  print "No query\n";
}

DESCRIPTION

NCGI::Query provides an interface to GET and POST queries sent by user agents.

METHODS

instance()

Return a reference to the current request. NCGI::Query is a Singleton class. See Class::Singleton on CPAN for details on what this means.

isquery()

Boolean indicating whether a GET or POST query was received.

isget()

Boolean indicating whether a GET query was received.

ispost()

Boolean indicating whether a POST query was received.

param()

Takes a single argument (the key) and returns the query value. Will return a list if called in array context. Useful for multiple parameters of the same name (eg. html multi option lists).

params()

Returns a reference to a HASH containing all query items.

full_query()

Returns the raw query string

cookie()

Takes a single argument (the cookie) and returns the cookie value.

cookies()

Returns a reference to a HASH containing all cookies

languages()

Returns an ordered list of preferred languages for this request. Basically a shortcut to I18N::LangTags::implicate_supers(I18N::LangTags::Detect::detect);

locales()

Returns an ordered list of preferred languages for this request, formatted for use by POSIX::setlocale. Browsers seem to give 'en-us' and the locale system has definitions called 'en_US'...

dump_params()

Returns a string representation of all query items and their values.

dump_cookies()

Returns a string representation of all cookies and their values.

SEE ALSO

NCGI::Singleton, NCGI::Cookie, NCGI

AUTHOR

Mark Lawrence <nomad@null.net>

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.