\section{cppcms\+:\+:http\+:\+:context Class Reference}
\label{classcppcms_1_1http_1_1context}\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}}


context is a central class that holds all specific connection related information. It encapsulates C\+GI request and response, cache, session and locale information  




{\ttfamily \#include $<$cppcms/http\+\_\+context.\+h$>$}

Inheritance diagram for cppcms\+:\+:http\+:\+:context\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classcppcms_1_1http_1_1context}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
enum {\bf completion\+\_\+type} \{ {\bf operation\+\_\+completed}, 
{\bf operation\+\_\+aborted}
 \}
\item 
typedef {\bf booster\+::callback}$<$ void({\bf completion\+\_\+type})$>$ {\bfseries handler}\label{classcppcms_1_1http_1_1context_af6f3005eb3252b98df96f87878e41560}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\bf http\+::request} \& {\bf request} ()
\item 
{\bf http\+::response} \& {\bf response} ()
\item 
{\bf json\+::value} const \& {\bf settings} ()
\item 
{\bf cache\+\_\+interface} \& {\bf cache} ()
\item 
{\bf session\+\_\+interface} \& {\bf session} ()
\item 
std\+::locale {\bf locale} ()
\item 
void {\bf locale} (std\+::locale const \&new\+\_\+locale)
\item 
void {\bf locale} (std\+::string const \&name)
\item 
{\bf cppcms\+::service} \& {\bf service} ()
\item 
std\+::string {\bf skin} ()
\item 
void {\bf skin} (std\+::string const \&name)
\item 
void {\bf complete\+\_\+response} ()
\item 
void {\bf async\+\_\+complete\+\_\+response} ()
\item 
void {\bf async\+\_\+flush\+\_\+output} ({\bf handler} const \&h)
\item 
void {\bf async\+\_\+on\+\_\+peer\+\_\+reset} ({\bf booster\+::callback}$<$ void()$>$ const \&h)
\item 
void {\bf submit\+\_\+to\+\_\+pool} ({\bf booster\+::shared\+\_\+ptr}$<$ {\bf application\+\_\+specific\+\_\+pool} $>$ pool, std\+::string const \&matched\+\_\+url)
\item 
void {\bf submit\+\_\+to\+\_\+asynchronous\+\_\+application} ({\bf booster\+::intrusive\+\_\+ptr}$<$ {\bf application} $>$ app, std\+::string const \&matched\+\_\+url)
\item 
{\footnotesize template$<$typename T $>$ }\\T $\ast$ {\bf get\+\_\+specific} ()
\item 
{\footnotesize template$<$typename T $>$ }\\void {\bf reset\+\_\+specific} (T $\ast$ptr=0)
\item 
{\footnotesize template$<$typename T $>$ }\\T $\ast$ {\bf release\+\_\+specific} ()
\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
class {\bfseries impl\+::cgi\+::connection}\label{classcppcms_1_1http_1_1context_a35a6637347117934569e84977b6f5143}

\end{DoxyCompactItemize}
\subsection*{Additional Inherited Members}


\subsection{Detailed Description}
context is a central class that holds all specific connection related information. It encapsulates C\+GI 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 H\+T\+TP request/response is completed 

\subsection{Member Enumeration Documentation}
\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!completion\+\_\+type@{completion\+\_\+type}}
\index{completion\+\_\+type@{completion\+\_\+type}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{completion\+\_\+type}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf cppcms\+::http\+::context\+::completion\+\_\+type}}\label{classcppcms_1_1http_1_1context_a826eb2e00a4d0ad73cfc6b0100c0d06f}
\begin{Desc}
\item[Enumerator]\par
\begin{description}
\index{operation\+\_\+completed@{operation\+\_\+completed}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!operation\+\_\+completed@{operation\+\_\+completed}}\item[{\em 
operation\+\_\+completed\label{classcppcms_1_1http_1_1context_a826eb2e00a4d0ad73cfc6b0100c0d06faa16dd3b6428f001023d759aa96bbfcd7}
}]Asynchronous operation completed successfully. \index{operation\+\_\+aborted@{operation\+\_\+aborted}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!operation\+\_\+aborted@{operation\+\_\+aborted}}\item[{\em 
operation\+\_\+aborted\label{classcppcms_1_1http_1_1context_a826eb2e00a4d0ad73cfc6b0100c0d06fa83b1e94e0179a4f4c9597350fadb104f}
}]Asynchronous operation was canceled. \end{description}
\end{Desc}


\subsection{Member Function Documentation}
\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!async\+\_\+complete\+\_\+response@{async\+\_\+complete\+\_\+response}}
\index{async\+\_\+complete\+\_\+response@{async\+\_\+complete\+\_\+response}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{async\+\_\+complete\+\_\+response()}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::async\+\_\+complete\+\_\+response (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a6d2c2128114b2c9f8cffd0bfe96dcd94}
Send all pending output data to the client and finalize the connection. Note, you can\textquotesingle{}t use this object for communication any more. \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!async\+\_\+flush\+\_\+output@{async\+\_\+flush\+\_\+output}}
\index{async\+\_\+flush\+\_\+output@{async\+\_\+flush\+\_\+output}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{async\+\_\+flush\+\_\+output(handler const \&h)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::async\+\_\+flush\+\_\+output (
\begin{DoxyParamCaption}
\item[{{\bf handler} const \&}]{h}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a134469b5dc46667596c360b8b7284dff}
Send all pending data to user, when operation is complete call handler {\itshape h} with status.

Note\+: if the status is operation\+\_\+aborted, you can\textquotesingle{}t use this connection any more, the peer gone. \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!async\+\_\+on\+\_\+peer\+\_\+reset@{async\+\_\+on\+\_\+peer\+\_\+reset}}
\index{async\+\_\+on\+\_\+peer\+\_\+reset@{async\+\_\+on\+\_\+peer\+\_\+reset}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{async\+\_\+on\+\_\+peer\+\_\+reset(booster\+::callback$<$ void()$>$ const \&h)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::async\+\_\+on\+\_\+peer\+\_\+reset (
\begin{DoxyParamCaption}
\item[{{\bf booster\+::callback}$<$ void()$>$ const \&}]{h}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a0f6fe53deabd90fee0ced81a8df6404e}
Set handler for peer reset events. It is useful to cleanup connections that had timeout or just disconnected by user

Notes\+:


\begin{DoxyEnumerate}
\item if async\+\_\+complete\+\_\+response was called, handler would not be called any more.
\item If async\+\_\+flush\+\_\+output fails, this does not mean that this handler would be called as well, so you need to check both 
\end{DoxyEnumerate}\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!cache@{cache}}
\index{cache@{cache}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{cache()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf cache\+\_\+interface}\& cppcms\+::http\+::context\+::cache (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a03a1a9094f04c6a14d66cb320d8b7ed0}
Get an interface to Cpp\+C\+MS Cache \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!complete\+\_\+response@{complete\+\_\+response}}
\index{complete\+\_\+response@{complete\+\_\+response}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{complete\+\_\+response()}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::complete\+\_\+response (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a073981554e99770a9f082eaa90af1bd9}
Send all pending output data to the client and finalize the connection. Note, you can\textquotesingle{}t use this object for communication any more. \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!get\+\_\+specific@{get\+\_\+specific}}
\index{get\+\_\+specific@{get\+\_\+specific}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{get\+\_\+specific()}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename T $>$ T$\ast$ cppcms\+::http\+::context\+::get\+\_\+specific (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classcppcms_1_1http_1_1context_ad94dd7968efd8efdc24d177500cfc8d8}
Get context specific value of type T binded to context. If none is stored or type mismatched N\+U\+LL is returned

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!locale@{locale}}
\index{locale@{locale}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{locale()}]{\setlength{\rightskip}{0pt plus 5cm}std\+::locale cppcms\+::http\+::context\+::locale (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a39fde738210daf84deee691f45260e5b}
Get current context locale 

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

\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!locale@{locale}}
\index{locale@{locale}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{locale(std\+::locale const \&new\+\_\+locale)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::locale (
\begin{DoxyParamCaption}
\item[{std\+::locale const \&}]{new\+\_\+locale}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a9d6ee6ce1d9007ba1c0d7222fa022fd8}
Set locale explicitly. Note, it changes the locale of the \doxyref{response()}{p.}{classcppcms_1_1http_1_1context_ac470c44432f9570e227330e974630872}.out() stream as well \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!locale@{locale}}
\index{locale@{locale}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{locale(std\+::string const \&name)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::locale (
\begin{DoxyParamCaption}
\item[{std\+::string const \&}]{name}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a036d52a76868c0736716b19e32b602a3}
Set locale by name. Similar to locale(\doxyref{service()}{p.}{classcppcms_1_1http_1_1context_a30c62fea3de87dabd6580f2257599a49}.generator(name)).

Note\+: it changes the locale of the \doxyref{response()}{p.}{classcppcms_1_1http_1_1context_ac470c44432f9570e227330e974630872}.out() stream as well \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!release\+\_\+specific@{release\+\_\+specific}}
\index{release\+\_\+specific@{release\+\_\+specific}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{release\+\_\+specific()}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename T $>$ T$\ast$ cppcms\+::http\+::context\+::release\+\_\+specific (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classcppcms_1_1http_1_1context_ad78ceacb71f189560bf53e98ce8ceddb}
Release context specific value binded to context.

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!request@{request}}
\index{request@{request}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{request()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf http\+::request}\& cppcms\+::http\+::context\+::request (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a79f5c6ad0f4dca64256abb0809d40cba}
Get an interface to H\+T\+TP request 

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

\index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!reset\+\_\+specific@{reset\+\_\+specific}}
\index{reset\+\_\+specific@{reset\+\_\+specific}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{reset\+\_\+specific(\+T $\ast$ptr=0)}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename T $>$ void cppcms\+::http\+::context\+::reset\+\_\+specific (
\begin{DoxyParamCaption}
\item[{T $\ast$}]{ptr = {\ttfamily 0}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classcppcms_1_1http_1_1context_a9ade01f327999cebf9f0f5a28fb7e9d8}
Reset context specific value of type T binded to context. Old value is deleted

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!response@{response}}
\index{response@{response}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{response()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf http\+::response}\& cppcms\+::http\+::context\+::response (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_ac470c44432f9570e227330e974630872}
Get an interface to H\+T\+TP response \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!service@{service}}
\index{service@{service}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{service()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf cppcms\+::service}\& cppcms\+::http\+::context\+::service (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a30c62fea3de87dabd6580f2257599a49}
Get the central service instance \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!session@{session}}
\index{session@{session}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{session()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf session\+\_\+interface}\& cppcms\+::http\+::context\+::session (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_abb47ca8cc18020efe394d26f590b6f97}
Get an interface to current session

Note, when using asynchronous Cpp\+C\+MS applications, session data is not fetched and is not updated, because session access may be not cheap, So when using \doxyref{session\+\_\+interface}{p.}{classcppcms_1_1session__interface} in asynchronous application make sure you call session\+\_\+inerface\+::load member function \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!settings@{settings}}
\index{settings@{settings}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{settings()}]{\setlength{\rightskip}{0pt plus 5cm}{\bf json\+::value} const\& cppcms\+::http\+::context\+::settings (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a3cd9ff89c81ae29259cbacbee2749fb4}
Get global settings. Same as \doxyref{cppcms\+::service\+::settings}{p.}{classcppcms_1_1service_a2655891c41745defac52587b4ecae53b} \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!skin@{skin}}
\index{skin@{skin}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{skin()}]{\setlength{\rightskip}{0pt plus 5cm}std\+::string cppcms\+::http\+::context\+::skin (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_ad6d98b1577946314257b7b9cbef1776c}
Get current views skin name \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!skin@{skin}}
\index{skin@{skin}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{skin(std\+::string const \&name)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::skin (
\begin{DoxyParamCaption}
\item[{std\+::string const \&}]{name}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_af1230c69d6824e220e0fcd35b29118bc}
Set current views skin name \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!submit\+\_\+to\+\_\+asynchronous\+\_\+application@{submit\+\_\+to\+\_\+asynchronous\+\_\+application}}
\index{submit\+\_\+to\+\_\+asynchronous\+\_\+application@{submit\+\_\+to\+\_\+asynchronous\+\_\+application}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{submit\+\_\+to\+\_\+asynchronous\+\_\+application(booster\+::intrusive\+\_\+ptr$<$ application $>$ app, std\+::string const \&matched\+\_\+url)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::submit\+\_\+to\+\_\+asynchronous\+\_\+application (
\begin{DoxyParamCaption}
\item[{{\bf booster\+::intrusive\+\_\+ptr}$<$ {\bf application} $>$}]{app, }
\item[{std\+::string const \&}]{matched\+\_\+url}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a317a093fabaebc36ac31afdf98c17ba7}
Submit the context to alternative application -\/ allows to transfer context from application to application, {\itshape matched\+\_\+url} would be given to \doxyref{application\+::main}{p.}{classcppcms_1_1application_a8c884a9309d107237e8946446feba8f8} for processing

Note\+:


\begin{DoxyItemize}
\item the app should be asynchronous
\item no output should be itransfered on this context
\item the context M\+U\+ST be detached for existing application
\end{DoxyItemize}

This function can be called from any thread

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::context@{cppcms\+::http\+::context}!submit\+\_\+to\+\_\+pool@{submit\+\_\+to\+\_\+pool}}
\index{submit\+\_\+to\+\_\+pool@{submit\+\_\+to\+\_\+pool}!cppcms\+::http\+::context@{cppcms\+::http\+::context}}
\subsubsection[{submit\+\_\+to\+\_\+pool(booster\+::shared\+\_\+ptr$<$ application\+\_\+specific\+\_\+pool $>$ pool, std\+::string const \&matched\+\_\+url)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::context\+::submit\+\_\+to\+\_\+pool (
\begin{DoxyParamCaption}
\item[{{\bf booster\+::shared\+\_\+ptr}$<$ {\bf application\+\_\+specific\+\_\+pool} $>$}]{pool, }
\item[{std\+::string const \&}]{matched\+\_\+url}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1context_a00ae7e77e6041d3ab6055ed792ccc5c2}
Submit the context to alternative pool -\/ allows to transfer context from application to application, {\itshape matched\+\_\+url} would be given to \doxyref{application\+::main}{p.}{classcppcms_1_1application_a8c884a9309d107237e8946446feba8f8} for processing

Note\+:


\begin{DoxyItemize}
\item no output should be itransfered on this context
\item the context M\+U\+ST be detached for existing application
\end{DoxyItemize}

This function can be called from any thread

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
cppcms/http\+\_\+context.\+h\end{DoxyCompactItemize}
