Dendral::HTTP::Request - Perl interface for Apache request variables
# Mod_perl handler use Dendral::HTTP::Request; sub handler { my $r = shift; my $req = new Dendral::HTTP::Request($r, POST_MAX => -1, MAX_FILES => -1, MAX_FILE_SIZE => -1, TMP_DIR => '/tmp'); # Retrieve parameter, sigle value my $foo = $req -> param('foo'); # Retrieve array or params my @foo = $req -> param('foo'); # Retrieve all given parameters my $all_params_hashref = $req -> params(); # Retrieve cookie by name my $bar_cookie = $req -> cookie('bar'); # Retrieve all given cookies my $all_cookies_hashref = $req -> cookies(); # Retrieve header value my $accept = $req -> header('Accept'); # Retrieve all given headers my $all_headers_hashref = $req -> headers(); # Get other request parameters such as host, method, query string, etc my $req_info = { host => $req -> host, method => $req -> method, request_time => $req -> request_time, the_request => $req -> the_request, protocol => $req -> protocol, unparsed_uri => $req -> unparsed_uri, uri => $req -> uri, filename => $req -> filename, path_info => $req -> path_info, args => $req -> args, remote_ip => $req -> remote_ip, local_ip => $req -> local_ip, port => $req -> port }; }
Dendral::HTTP::Request is a part of Dendral - fast, reliable and lightweight MVC framework. This module is very similar to well-known Apache::Request.
Create a new Dendral::HTTP::Request object with an Apache request_rec object: my $req = new Dendral::HTTP::Request($r, POST_MAX => -1, MAX_FILES => -1, MAX_FILE_SIZE => -1, TMP_DIR => '/tmp'); MAX_POST, POST_MAX - Limit of POST request size, bytes; -1 means no limit, 0 - POST method is disabled. TMP_DIR, TEMP_DIR, TEMPFILE_DIR - Directory where upload files are spooled, default is /tmp. MAX_FILES - Limit of number of files; -1 means no limit, 0 - uploading of files is disabled. MAX_FILE_SIZE - Uploaded file size limit, bytes; -1 means no limit, 0 - uploading of files is disabled. DIE_ON_ERRORS - If set, module should die if any error occured.
my $foo = $req -> param('foo'); my @foo = $req -> param('foo'); my $all_params_hashref = $req -> param();
my $all_params_hashref = $req -> params();
my $bar_cookie = $req -> cookie('bar'); my @bar_cookie = $req -> cookie('bar'); my $all_cookies_hashref = $req -> cookie();
my $all_cookies_hashref = $req -> cookies();
my $accept_header = $req -> header('Accept'); my @accept_header = $req -> header('Accept'); my $all_headers_hashref = $req -> header();
my $all_headers_hashref = $req -> headers();
my $port = $req -> port();
my $host = $req -> host();
my $protocol = $req -> protocol();
my $method = $req -> method();
my $query_string_args = $req -> args();
my $path_info = $req -> path_info();
my $filename = $req -> filename();
my $uri = $req -> uri();
my $unparsed_uri = $req -> unparsed_uri();
my $the_request = $req -> the_request();
my $request_time = $req -> request_time();
my $local_ip = $req -> local_ip();
my $remote_ip = $req -> remote_ip();
my $raw_post_data = $req -> raw();
my $file = $req -> file('upload_file'); my @files = $req -> file(); my $file_name = $file -> {'file_name'}; my $tmp_name = $file -> {'tmp_name'}; my $full_filename = $file -> {'full_filename'}; my $filesize = $file -> {'filesize'}; my $content_type = $file -> {'content_type'}; my $content_tr_enc = $file -> {'content_transfer_encoding'};
See file examples/Mytest.pm
Andrei V. Shetuhin (reki@reki.ru)
perl(1), Apache(3), Apache::Request(3)
http://dendral.havoc.ru/en/ - in English
http://dendral.havoc.ru/ - for Russian speakers
Copyright (c) 2005 - 2011 CAS Dev Team Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 4. Neither the name of the CAS Dev. Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To install Dendral::HTTP::Request, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dendral::HTTP::Request
CPAN shell
perl -MCPAN -e shell install Dendral::HTTP::Request
For more information on module installation, please visit the detailed CPAN module installation guide.