Jifty::Manual::RequestHandling - Jifty's request handling process
This document outlines some of Jifty's inside in order to help you to understand what happens during the request processing phase.
As soon as a HTTP request (whatever the method might be,
...) arrives at Jifty's border,
the request is forwarded to a handler.
Jifty->handler points to a Jifty::Handler object that is responsible for handling an incoming request.
The handler receives a CGI object on which it operates.
This allows a perl developer to change perl modules being used in a Jifty application without the need to restart the server which would otherwise become necessary. This is never done on a live environment.
The stash is a storage area that can be reached by simply accessing
The stash will start fresh with every request and lives for the entire lifetime of a request.
Using the stash,
transporting data between otherwise unconnected modules will become possible.
Using the CGI object,
a Jifty::Request object is constructed and its data is populated with the CGI object's data.
The request can be reached later using
The request holds information about all actions involved,
all page fragments,
contains state variables and arguments (usually GET/POST parameters).
an empty Jifty::Response object is constructed that contains one or more Jifty::Result objects,
each of which holds one Jifty::Action's result.
The response object can be retrieved with the
For every registered Jifty::Plugin, some kind of per-request initialization is performed allowing the actions provided by each plugin to run.
If the requested URI points to some existing static content being housed in a
this content is handled.
Based on a cookie that is sent with every HTTP response,
the current user is assigned a unique session.
The session is stored in a Jifty::Web::Session object and can be accessed using the
If there is an open continuation on the stack (e.g.
Jifty->web->tangent link) and the return has been requested (e.g.
the return will execute at this stage.
the user is given a cookie containing the session-id.
the request is forwarded to
a Jifty::Dispatcher object to handle the request.
The dispatcher works through the following steps:
In this stage,
all rules in the dispatcher that are marked with the word
before are run.
Every Jifty::Action that is registered in a form or involved in a link or button is run in this stage.
This stage is responsible for working through all rules marked by words like
when and so on.
This is a point where based on the URI or parameters the template to get displayed may still be modified,
data get retrieved,
additional actions run or the template's parameters get adjusted.
Here, the template displaying the page is run.
This final stage of the dispatcher will run all rules marked with the word
Finally, the eventually modified session-record is flushed and some internally allocated structures get deallocated.