Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

HTML::Mason::CGIHandler

Name HTML::Mason::CGIHandler
Version 1.59
Located at /usr/share/perl5
File /usr/share/perl5/HTML/Mason/CGIHandler.pm
Is Core No
Search CPAN for this module HTML::Mason::CGIHandler
Documentation HTML::Mason::CGIHandler
Module Details HTML::Mason::CGIHandler

NAME

HTML::Mason::CGIHandler - Use Mason in a CGI environment


SYNOPSIS

In httpd.conf or .htaccess:

    <LocationMatch "\.html$">
        Action html-mason /cgi-bin/mason_handler.cgi
        AddHandler html-mason .html
    </LocationMatch>
    <LocationMatch "^/cgi-bin/">
        RemoveHandler .html
    </LocationMatch>
    <FilesMatch "(autohandler|dhandler)$">
        Order allow,deny
        Deny from all
    </FilesMatch>

A script at /cgi-bin/mason_handler.pl :

   #!/usr/bin/perl
   use HTML::Mason::CGIHandler;
   my $h = HTML::Mason::CGIHandler->new
    (
     data_dir  => '/home/jethro/code/mason_data',
     allow_globals => [qw(%session $u)],
    );
   $h->handle_request;

A .html component somewhere in the web server's document root:

   <%args>
    $mood => 'satisfied'
   </%args>
   % $r->err_header_out(Location => "http://blahblahblah.com/moodring/$mood.html");
   ...


DESCRIPTION

This module lets you execute Mason components in a CGI environment. It lets you keep your top-level components in the web server's document root, using regular component syntax and without worrying about the particular details of invoking Mason on each request.

If you want to use Mason components from within a regular CGI script (or any other Perl program, for that matter), then you don't need this module. You can simply follow the directions in the Using Mason from a standalone script section of the administrator's manual.

This module also provides an $r request object for use inside components, similar to the Apache request object under HTML::Mason::ApacheHandler, but limited in functionality. Please note that we aim to replicate the mod_perl functionality as closely as possible - if you find differences, do not depend on them to stay different. We may fix them in a future release. Also, if you need some missing functionality in $r, let us know, we might be able to provide it.

Finally, this module alters the HTML::Mason::Request object $m to provide direct access to the CGI query, should such access be necessary.

HTML::Mason::CGIHandler Methods

$r Methods

Added $m methods

The $m object provided in components has all the functionality of the regular HTML::Mason::Request object $m, and the following:

HTML::Mason::FakeTable Methods

This class emulates the behavior of the Apache::Table class, and is used to store manage the tables of values for the following attributes of <$r>:

headers_inheaders_in
headers_outheaders_out
err_headers_outerr_headers_out
notesnotes
subprocess_envsubprocess_env

HTML::Mason::FakeTable is designed to behave exactly like Apache::Table, and differs in only one respect. When a given key has multiple values in an Apache::Table object, one can fetch each of the values for that key using Perl's each operator:

  while (my ($k, $v) = each %{$r->headers_out}) {
      push @cookies, $v if lc $k eq 'set-cookie';
  }

If anyone knows how Apache::Table does this, let us know! In the meantime, use get() or do() to get at all of the values for a given key (get() is much more efficient, anyway).

Since the methods named for these attributes return an HTML::Mason::FakeTable object hash in a scalar reference, it seemed only fair to document its interface.

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026