CppCMS
Public Types | Public Member Functions
cppcms::http::context Class Reference

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>

Inheritance diagram for cppcms::http::context:
booster::noncopyable booster::enable_shared_from_this< context >

List of all members.

Public Types

enum  completion_type { operation_completed, operation_aborted }
typedef booster::callback
< void(completion_type)> 
handler

Public Member Functions

http::requestrequest ()
http::responseresponse ()
json::value const & settings ()
cache_interfacecache ()
session_interfacesession ()
std::locale locale ()
void locale (std::locale const &new_locale)
void locale (std::string const &name)
cppcms::serviceservice ()
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)

Detailed Description

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


Member Enumeration Documentation

Enumerator:
operation_completed 

Asynchronous operation completed successfully.

operation_aborted 

Asynchronous operation was canceled.


Member Function Documentation

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:

  1. if async_complete_response was called, handler would not be called any more.
  2. If async_flush_output fails, this does not mean that this handler would be called as well, so you need to check both

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.

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

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


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