#include <request.hpp>
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. | |
Transceiver * | transceiver |
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 |
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.
charT | Character type for internal processing (wchar_t or char) |
Definition at line 59 of file request.hpp.
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().
void Fastcgipp::Request< charT >::complete | ( | ) | [inline, private] |
Generates an END_REQUEST FastCGI record.
Definition at line 141 of file request.cpp.
References Fastcgipp::Protocol::END_REQUEST, Fastcgipp::Request< charT >::err, Fastcgipp::Request< charT >::killCon, Fastcgipp::Request< charT >::out, Fastcgipp::Protocol::REQUEST_COMPLETE, Fastcgipp::Transceiver::requestWrite(), Fastcgipp::Transceiver::secureWrite(), Fastcgipp::Request< charT >::transceiver, and Fastcgipp::Protocol::version.
Referenced by Fastcgipp::Request< charT >::handler().
bool Fastcgipp::Request< charT >::handler | ( | ) | [inline, private] |
Request Handler.
This function is called by Manager::handler() to handle messages destined for the request. It deals with FastCGI messages (type=0) while passing all other messages off to response().
Definition at line 179 of file request.cpp.
References Fastcgipp::Protocol::ABORT_REQUEST, Fastcgipp::Request< charT >::complete(), Fastcgipp::Message::data, Fastcgipp::Protocol::END_REQUEST, Fastcgipp::Request< charT >::err, Fastcgipp::Protocol::IN, Fastcgipp::Request< charT >::inHandler(), Fastcgipp::Request< charT >::killCon, Fastcgipp::Request< charT >::message, Fastcgipp::Request< charT >::messages, Fastcgipp::Protocol::OUT, Fastcgipp::Protocol::PARAMS, Fastcgipp::Transceiver::requestWrite(), Fastcgipp::Protocol::RESPONDER, Fastcgipp::Request< charT >::response(), Fastcgipp::Request< charT >::role, Fastcgipp::Transceiver::secureWrite(), Fastcgipp::Request< charT >::session, Fastcgipp::Request< charT >::state, Fastcgipp::Request< charT >::transceiver, Fastcgipp::Message::type, Fastcgipp::Protocol::UNKNOWN_ROLE, and Fastcgipp::Protocol::version.
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.
[in] | bytesReceived | Amount of bytes received in this FastCGI record |
Definition at line 106 of file request.hpp.
Referenced by Fastcgipp::Request< charT >::handler().
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).
Referenced by Fastcgipp::Request< charT >::handler().
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.
[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.
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.
[in] | loc_ | New locale |
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().
friend class Manager [friend] |
Definition at line 164 of file request.hpp.
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().
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().
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.
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().
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().
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.
Definition at line 118 of file request.hpp.
Referenced by Fastcgipp::Request< charT >::handler().
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().
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().
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().
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().
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().
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().