Andrew Sterling Hanenkamp > Contentment-0.011_033 > Contentment::Request

Download:
Contentment-0.011_033.tar.gz

Dependencies

Annotate this POD

Module Version: 0.011_033   Source  

NAME ^

Contentment::Request - Class responsible for managing incoming requests

DESCRIPTION ^

This class consumes an HTTP request and then presents the current request through the interface provided. Contentment is meant to target different web platforms (CGI, FastCGI, libwww-perl, mod_perl, etc.). Each of these present a different API for accessing the HTTP request information. This interface tries to simplify things by presenting a uniform request interface for all.

Rather than re-invent yet another interface to add to the list above, we'd rather just use an existing object. We use CGI to present this interface. It's not ideal because it also presents a lot of response functionality that should be found in Contentment::Response. However, it is the only interface that is both popular and works uniformly with nearly any target platform with very little effort. This also gives you additional functionality, such as HTML code generation, fill-in form generation, and some other tools that might also be useful in your code. However, the returning of response information is the job of Contentment::Response, so these features of CGI will remain unused (though, Contentment::Response probably uses them internally as they are quite handy).

METHODS

$request = $context->request

Before using any of the other methods of this class, you must first get a reference to the request object. This method is valid for anything happening during or after the "Contentment::Request::begin" hook until after the "Contentment::Request::end" hook finishes.

$query = $request->cgi

Retrieves a copy of the CGI object or undef if the request hasn't be initialized yet.

$kind = $request->final_kind

This method may be called to ask what kind of file the request wants returned. This involves calling the "Contentment::Request::final_kind" hook. The hook will be called at most once per request and the result will be cached here if this method is called more than once. If no handlers are set or none of the called handlers can identify the final kind, then the empty string ("") will be returned.

Contentment::Request->begin_cgi($ctx)

This shouldn't be called outside of a Contentment handler method. It tells the handler to load the request from standard input and the environment.

This calls the Contentment::Request::begin hook.

Contemtent::Request->end_cgi

This shouldn't be called outside of a Contentment handler method. It calls the Contentment::Request::end hook.

Contentment::Request->begin_fast_cgi

This shouldn't be called outside of a Contentment handler method. It tells the handler to the load the FastCGI request.

This calls the Contentment::Request::begin hook.

Contentment::Request->end_fast_cgi

This shouldn't be called outside of a Contentment handler method. It calls the Contentment::Request::end hook.

CONTEXT

This class adds the following context methods:

$request = $context->request

Fetches the request object for the current request.

$cgi = $context->cgi

This is a short cut for:

  $cgi = $context->request->cgi;

HOOKS

Contentment::Request::begin

These handlers are passed a single argument. This will be a copy of the context object.

Contentment::Request::end

These handlers are passed a single argument. This will be a copy of the context object.

Contentment::Request::final_kind

These handlers are passed a single argument. This will be a copy of the context object.

These handlers should try to identify the kind of file the request wants rendered. The file "kind" is a bit of a nebulous idea, but is often a MIME Type or something similar and can be used by various plugins to figure out how to render the page. The first handler that returns a value other than undef forms the result of the hook. The rest of the handlers will not be called.

AUTHOR ^

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT ^

Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.

Contentment is licensed and distributed under the same terms as Perl itself.

syntax highlighting: