The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Mason::Request - Mason Request Class

SYNOPSIS

    $REQ->...

DESCRIPTION

Mason creates one Request object for every web request (or, in stand-alone mode, every Interp::exec call). Inside a component you access the current request object via the global $REQ.

Prior to version 0.7, the only way to access request information was through specific mc_ commands. For this reason many of the methods below have mc_ command equivalents; you are free to use either interface.

METHODS

abort ([return value])

Ends the current request, finishing the page without returning through components. The optional argument specifies the return value from Interp::exec; in a web environment, this ultimately becomes the HTTP status code. This method is used to implement mc_abort.

call (comp, option=>value, ...[, STORE=>ref])

Calls the component designated by comp with the specified option/value pairs. comp may be an absolute or relative component path, or a component object.

The optional STORE option causes all output to be placed in the scalar reference provided instead of being sent to the default output stream.

This method is used to implement mc_comp and the <& &> tag.

callers

With no arguments, returns the current component stack as a list of component objects, starting with the current component and ending with the top-level component. With one numeric argument, returns the component object at that index in the list. e.g.

    $REQ->callers(0)      # current component
    $REQ->callers(1)      # component that called us
    $REQ->callers(-1)     # top-level component
comp

Returns the current component object.

count

Returns the number of this request, which is unique for a given request and interpreter.

depth

Returns the current size of the component stack. The lowest possible value is 1, which indicates we are in the top-level component.

dhandler_arg

If the request has been handled by a dhandler, this method returns the remainder of the URI or Interp::exec path when the dhandler directory is removed. Otherwise returns undef. This method is used to implement mc_dhandler_arg.

fetch_comp (compPath)

Given an absolute or relative component path, returns the corresponding component object or undef if no such component exists. Looks for subcomponents as well as file-based components.

interp

Returns the Interp object associated with this request.

parser

Returns the Parser object associated with this request.

process_comp_path (compPath)

Given an absolute or relative component path, returns the corresponding absolute component path.

APACHE-ONLY METHODS

These additional methods are available when running Mason with mod_perl and the ApacheHandler.

ah

Returns the ApacheHandler object associated with this request.

http_input

Returns the input string for this HTTP request: for GET, the query string, and for POST, the content block read from the client. Because $r->content can only be called once and is automatically called by Mason, it cannot be called directly inside components; this method is a good way to get at the value of $r->content.

apache_req

Returns the Apache request object. This is also available in the global $r.

AUTHOR

Jonathan Swartz, swartz@transbay.net

SEE ALSO

HTML::Mason::Component