CppCMS
|
context is a central class that holds all specific connection related information. It encapsulates CGI request and response, cache, session and locale information More...
#include <cppcms/http_context.h>
Public Types | |
enum | completion_type { operation_completed, operation_aborted } |
typedef booster::callback < void(completion_type)> | handler |
Public Member Functions | |
http::request & | request () |
http::response & | response () |
json::value const & | settings () |
cache_interface & | cache () |
session_interface & | session () |
std::locale | locale () |
void | locale (std::locale const &new_locale) |
void | locale (std::string const &name) |
cppcms::service & | service () |
std::string | skin () |
void | skin (std::string const &name) |
void | complete_response () |
void | async_complete_response () |
void | async_flush_output (handler const &h) |
void | async_on_peer_reset (booster::callback< void()> const &h) |
context is a central class that holds all specific connection related information. It encapsulates CGI request and response, cache, session and locale information
Instance of this class is created upon client requests, it provides access to all connection related interfaces. This class is unique per each applications hierarchy and destroyed when HTTP request/response is completed
Send all pending output data to the client and finalize the connection. Note, you can't use this object for communication any more.
void cppcms::http::context::async_flush_output | ( | handler const & | h | ) |
Send all pending data to user, when operation is complete call handler h with status.
Note: if the status is operation_aborted, you can't use this connection any more, the peer gone.
void cppcms::http::context::async_on_peer_reset | ( | booster::callback< void()> const & | h | ) |
Set handler for peer reset events. It is useful to cleanup connections that had timeout or just disconnected by user
Notes:
Get an interface to CppCMS Cache
Send all pending output data to the client and finalize the connection. Note, you can't use this object for communication any more.
std::locale cppcms::http::context::locale | ( | ) |
Get current context locale
Referenced by cppcms::widgets::numeric< T >::load().
void cppcms::http::context::locale | ( | std::locale const & | new_locale | ) |
Set locale explicitly. Note, it changes the locale of the response().out() stream as well
void cppcms::http::context::locale | ( | std::string const & | name | ) |
Set locale by name. Similar to locale(service().generator(name)).
Note: it changes the locale of the response().out() stream as well
Get an interface to HTTP request
Referenced by cppcms::widgets::numeric< T >::load().
Get an interface to HTTP response
Get the central service instance
Get an interface to current session
Note, when using asynchronous CppCMS applications, session data is not fetched and is not updated, because session access may be not cheap, So when using session_interface in asynchronous application make sure you call session_inerface::load member function
json::value const& cppcms::http::context::settings | ( | ) |
Get global settings. Same as cppcms::service::settings
std::string cppcms::http::context::skin | ( | ) |
Get current views skin name
void cppcms::http::context::skin | ( | std::string const & | name | ) |
Set current views skin name