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

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

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

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

Get an interface to HTTP request

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

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

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

- cppcms/http_context.h