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) |
void | submit_to_pool (booster::shared_ptr< application_specific_pool > pool, std::string const &matched_url) |
void | submit_to_asynchronous_application (booster::intrusive_ptr< application > app, std::string const &matched_url) |
template<typename T > | |
T * | get_specific () |
template<typename T > | |
void | reset_specific (T *ptr=0) |
template<typename T > | |
T * | release_specific () |
Public Member Functions inherited from booster::enable_shared_from_this< context > | |
shared_ptr< context > | shared_from_this () |
shared_ptr< contextconst > | shared_from_this () const |
void | _internal_accept_owner (shared_ptr< X > const *ppx, Y *py) const |
Friends | |
class | impl::cgi::connection |
Additional Inherited Members | |
Protected Member Functions inherited from booster::enable_shared_from_this< context > | |
enable_shared_from_this (enable_shared_from_this const &) | |
enable_shared_from_this & | operator= (enable_shared_from_this const &) |
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
void cppcms::http::context::async_complete_response | ( | ) |
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:
cache_interface& cppcms::http::context::cache | ( | ) |
Get an interface to CppCMS Cache
void cppcms::http::context::complete_response | ( | ) |
Send all pending output data to the client and finalize the connection. Note, you can't use this object for communication any more.
|
inline |
Get context specific value of type T binded to context. If none is stored or type mismatched NULL is returned
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
|
inline |
Release context specific value binded to context.
http::request& cppcms::http::context::request | ( | ) |
Get an interface to HTTP request
Referenced by cppcms::widgets::numeric< T >::load().
|
inline |
Reset context specific value of type T binded to context. Old value is deleted
http::response& cppcms::http::context::response | ( | ) |
Get an interface to HTTP response
cppcms::service& cppcms::http::context::service | ( | ) |
Get the central service instance
session_interface& cppcms::http::context::session | ( | ) |
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
void cppcms::http::context::submit_to_asynchronous_application | ( | booster::intrusive_ptr< application > | app, |
std::string const & | matched_url | ||
) |
Submit the context to alternative application - allows to transfer context from application to application, matched_url would be given to application::main for processing
Note:
This function can be called from any thread
void cppcms::http::context::submit_to_pool | ( | booster::shared_ptr< application_specific_pool > | pool, |
std::string const & | matched_url | ||
) |
Submit the context to alternative pool - allows to transfer context from application to application, matched_url would be given to application::main for processing
Note:
This function can be called from any thread