added: to Request:
// used as a JSON output (when ajax_serializer is defined)
// it will be serialized and have at least:
// 'content' string - the whole html content
// 'http_status' integer - http status code (e.g. 200)
PT::Space ajax;
// if not null then the request will have a JSON as an output
PT::SpaceToJSON * ajax_serializer;
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@871 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
20
core/app.cpp
20
core/app.cpp
@@ -451,6 +451,14 @@ bool sent = false;
|
||||
{
|
||||
templates.Generate();
|
||||
}
|
||||
|
||||
|
||||
if( cur.request->ajax_serializer )
|
||||
{
|
||||
std::wstring & ajax_content = cur.request->ajax.Add(L"content", L"");
|
||||
ajax_content = cur.request->page.Str();
|
||||
cur.request->ajax_serializer->Serialize(cur.request->ajax, cur.request->ajaxpage, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1038,13 +1046,19 @@ void App::AddDebugInfo(std::wstring & out)
|
||||
|
||||
void App::SendAnswer()
|
||||
{
|
||||
const std::wstring & source = cur.request->page.Str();
|
||||
const std::wstring * source;
|
||||
Header header = h_200;
|
||||
Error status = cur.request->status;
|
||||
bool compressing;
|
||||
int compress_encoding;
|
||||
|
||||
SelectCompression(source.length(), compressing, compress_encoding);
|
||||
if( cur.request->ajax_serializer )
|
||||
source = &cur.request->ajaxpage.Str();
|
||||
else
|
||||
source = &cur.request->page.Str();
|
||||
|
||||
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
|
||||
header = h_404;
|
||||
@@ -1057,7 +1071,7 @@ int compress_encoding;
|
||||
if( CanSendContent(header) )
|
||||
{
|
||||
// filtering (html), compressing and sending back to the web browser
|
||||
FilterCompressSend(compressing, compress_encoding, source);
|
||||
FilterCompressSend(compressing, compress_encoding, *source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user