CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Friends | List of all members
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:

## 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 &)

## 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

enum cppcms::http::context::completion_type

Enumerator
operation_completed | Asynchronous operation completed successfully.
operation_aborted | Asynchronous operation was canceled.

## Member Function Documentation

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:

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

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.

template<typename T >

T* cppcms::http::context::get_specific | ( |  | ) |
| inline

Get context specific value of type T binded to context. If none is stored or type mismatched NULL is returned

New in CppCMS 1.2

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

template<typename T >

T* cppcms::http::context::release_specific | ( |  | ) |
| inline

Release context specific value binded to context.

New in CppCMS 1.2

http::request& cppcms::http::context::request | ( |  | ) |

Get an interface to HTTP request

Referenced by cppcms::widgets::numeric< T >::load().

template<typename T >

void cppcms::http::context::reset_specific | ( | T * | ptr = `0` | ) |
| inline

Reset context specific value of type T binded to context. Old value is deleted

New in CppCMS 1.2

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:

- the app should be asynchronous
- no output should be itransfered on this context
- the context MUST be detached for existing application

This function can be called from any thread

New in CppCMS 1.2

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:

- no output should be itransfered on this context
- the context MUST be detached for existing application

This function can be called from any thread

New in CppCMS 1.2

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

- cppcms/http_context.h