Fastcgipp::Request< charT > Class Template Reference

Request handling class More...

#include <request.hpp>

List of all members.

Classes

class  Messages
 Queue type for pending messages. More...

Public Member Functions

 Request ()
 Initializes what it can. set() must be called by Manager before the data is usable.

Protected Member Functions

virtual bool response ()=0
 Response generator.
virtual void inHandler (int bytesReceived)
 Generate a data input response.
void setloc (std::locale loc_)
 Set the requests locale.

Protected Attributes

Http::Session< charT > session
 Structure containing all HTTP session data.
Fcgistream< charT,
std::char_traits< charT > > 
out
 Standard output stream to the client.
Fcgistream< charT,
std::char_traits< charT > > 
err
 Output stream to the HTTP server error log.
std::locale loc
 The locale associated with the request. Should be set with setloc(), not directly.
Message message
 The message associated with the current handler() call.
boost::function< void(Message)> callback
 Callback function for dealings outside the fastcgi++ library.

Private Member Functions

bool handler ()
 Request Handler.
void complete ()
 Generates an END_REQUEST FastCGI record.
void set (Protocol::FullId id_, Transceiver &transceiver_, Protocol::Role role_, bool killCon_, boost::function< void(Message)> callback_)
 Set's up the request with the data it needs.

Private Attributes

Messages messages
 A queue of messages to be handler by the request.
Transceivertransceiver
 Pointer to the transceiver object that will send data to the other side.
Protocol::Role role
 The role that the other side expects this request to play.
Protocol::FullId id
 The complete ID (request id & file descriptor) associated with the request.
bool killCon
 Boolean value indicating whether or not the file descriptor should be closed upon completion.
Protocol::RecordType state
 What the request is current doing.

Friends

class Manager


Detailed Description

template<class charT>
class Fastcgipp::Request< charT >

Request handling class

Derivations of this class will handle requests. This includes building the session data, processing post/get data, fetching data (files, database), and producing a response. Once all client data is organized, response() will be called. At minimum, derivations of this class must define response().

If you want to use UTF-8 encoding pass wchar_t as the template argument, use setloc() to setup a UTF-8 locale and use wide character unicode internally for everything. If you want to use a 8bit character set encoding pass char as the template argument and setloc() a locale with the corresponding character set.

Template Parameters:
charT Character type for internal processing (wchar_t or char)

Definition at line 59 of file request.hpp.


Constructor & Destructor Documentation

template<class charT >
Fastcgipp::Request< charT >::Request (  )  [inline]

Initializes what it can. set() must be called by Manager before the data is usable.

Definition at line 63 of file request.hpp.

References Fastcgipp::Request< charT >::out, Fastcgipp::Request< charT >::session, and Fastcgipp::Request< charT >::setloc().


Member Function Documentation

template<class charT >
void Fastcgipp::Request< charT >::complete (  )  [inline, private]

template<class charT >
bool Fastcgipp::Request< charT >::handler (  )  [inline, private]

template<class charT >
virtual void Fastcgipp::Request< charT >::inHandler ( int  bytesReceived  )  [inline, protected, virtual]

Generate a data input response.

This function exists should the library user wish to do something like generate a partial response based on bytes received from the client. The function is called by handler() every time a FastCGI IN record is received. The function has no access to the data, but knows exactly how much was received based on the value that was passed. Note this value represents the amount of data received in the individual record, not the total amount received in the session. If the library user wishes to have such a value they would have to keep a tally of all size values passed.

Parameters:
[in] bytesReceived Amount of bytes received in this FastCGI record

Definition at line 106 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler().

template<class charT >
virtual bool Fastcgipp::Request< charT >::response (  )  [protected, pure virtual]

Response generator.

This function is called by handler() once all request data has been received from the other side or if a Message not of a FastCGI type has been passed to it. The function shall return true if it has completed the response and false if it has not (waiting for a callback message to be sent).

Returns:
Boolean value indication completion (true means complete)
See also:
callback

Referenced by Fastcgipp::Request< charT >::handler().

template<class charT >
void Fastcgipp::Request< charT >::set ( Protocol::FullId  id_,
Transceiver transceiver_,
Protocol::Role  role_,
bool  killCon_,
boost::function< void(Message)>  callback_ 
) [inline, private]

Set's up the request with the data it needs.

This function is an "after-the-fact" constructor that build vital initial data for the request.

Parameters:
[in] id_ Complete ID of the request
[in] transceiver_ Transceiver object the request will use
[in] role_ The role that the other side expects this request to play
[in] killCon_ Boolean value indicating whether or not the file descriptor should be closed upon completion
[in] callback_ Callback function capable of passing messages to the request

Definition at line 187 of file request.hpp.

References Fastcgipp::Request< charT >::callback, Fastcgipp::Protocol::ERR, Fastcgipp::Request< charT >::err, Fastcgipp::Request< charT >::killCon, Fastcgipp::Protocol::OUT, Fastcgipp::Request< charT >::out, Fastcgipp::Request< charT >::role, Fastcgipp::Fcgistream< charT, traits >::set(), and Fastcgipp::Request< charT >::transceiver.

template<class charT >
void Fastcgipp::Request< charT >::setloc ( std::locale  loc_  )  [inline, protected]

Set the requests locale.

This function both sets loc to the locale passed to it and imbues the locale into the out and err stream. The user should always call this function as opposed to setting the locales directly is this functions insures the utf8 code conversion is functioning properly.

Parameters:
[in] loc_ New locale
See also:
loc

out

Definition at line 277 of file request.cpp.

References Fastcgipp::Request< charT >::err, Fastcgipp::Request< charT >::loc, and Fastcgipp::Request< charT >::out.

Referenced by Fastcgipp::Request< charT >::Request().


Friends And Related Function Documentation

template<class charT >
friend class Manager [friend]

Definition at line 164 of file request.hpp.


Member Data Documentation

template<class charT >
boost::function<void(Message)> Fastcgipp::Request< charT >::callback [protected]

Callback function for dealings outside the fastcgi++ library.

The purpose of the callback object is to provide a thread safe mechanism for functions and classes outside the fastcgi++ library to talk to the requests. Should the library wish to have another thread process or fetch some data, that thread can call this function when it is finished. It is equivalent to this:

void callback(Message msg);

The sole parameter is a Message that contains both a type value for processing by response() and the raw castable data.

Definition at line 144 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::set().

template<class charT >
Fcgistream<charT, std::char_traits<charT> > Fastcgipp::Request< charT >::err [protected]

Output stream to the HTTP server error log.

To dump data directly through the stream without it being code converted and bypassing the stream buffer call Fcgistream::dump()

Definition at line 82 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Request< charT >::handler(), Fastcgipp::Request< charT >::set(), and Fastcgipp::Request< charT >::setloc().

template<class charT >
Protocol::FullId Fastcgipp::Request< charT >::id [private]

The complete ID (request id & file descriptor) associated with the request.

Definition at line 170 of file request.hpp.

template<class charT >
bool Fastcgipp::Request< charT >::killCon [private]

Boolean value indicating whether or not the file descriptor should be closed upon completion.

Definition at line 172 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Request< charT >::handler(), and Fastcgipp::Request< charT >::set().

template<class charT >
std::locale Fastcgipp::Request< charT >::loc [protected]

The locale associated with the request. Should be set with setloc(), not directly.

Definition at line 106 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::setloc().

template<class charT >
Message Fastcgipp::Request< charT >::message [protected]

The message associated with the current handler() call.

This is only of use to the library user when a non FastCGI (type=0) Message is passed by using the requests callback.

See also:
callback

Definition at line 118 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler().

template<class charT >
Messages Fastcgipp::Request< charT >::messages [private]

A queue of messages to be handler by the request.

Definition at line 153 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler().

template<class charT >
Fcgistream<charT, std::char_traits<charT> > Fastcgipp::Request< charT >::out [protected]

Standard output stream to the client.

To dump data directly through the stream without it being code converted and bypassing the stream buffer call Fcgistream::dump()

Definition at line 76 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Request< charT >::Request(), Fastcgipp::Request< charT >::set(), and Fastcgipp::Request< charT >::setloc().

template<class charT >
Protocol::Role Fastcgipp::Request< charT >::role [private]

The role that the other side expects this request to play.

Definition at line 168 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler(), and Fastcgipp::Request< charT >::set().

template<class charT >
Http::Session<charT> Fastcgipp::Request< charT >::session [protected]

Structure containing all HTTP session data.

Definition at line 67 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler(), and Fastcgipp::Request< charT >::Request().

template<class charT >
Protocol::RecordType Fastcgipp::Request< charT >::state [private]

What the request is current doing.

Definition at line 174 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::handler().

template<class charT >
Transceiver* Fastcgipp::Request< charT >::transceiver [private]

Pointer to the transceiver object that will send data to the other side.

Definition at line 166 of file request.hpp.

Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Request< charT >::handler(), and Fastcgipp::Request< charT >::set().


The documentation for this class was generated from the following files:

Generated on Thu Dec 11 01:47:28 2008 for fastcgi++ by  doxygen 1.5.7.1