updated to the new Ezc API
[ezc stream] has gone, now we have [ezc out] and [out] the output streams have names now: it's a std::map, before we have a std::vector and the streams are serialized to "out" space in json Request::out_streams[] are split into Request::out_main_stream and Request::out_streams class git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1017 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
56
core/app.cpp
56
core/app.cpp
@@ -554,16 +554,27 @@ void App::CreateJSONAnswer()
|
||||
|
||||
if( !req.return_info_only )
|
||||
{
|
||||
json_out_stream << L"{\n";
|
||||
json_out_stream << L"{\n\"out\": {\n";
|
||||
|
||||
for(size_t i=1 ; i<req.out_streams.size() ; ++i)
|
||||
auto i = req.out_streams.streams_map.begin();
|
||||
bool is_first = true;
|
||||
|
||||
for( ; i != req.out_streams.streams_map.end() ; ++i)
|
||||
{
|
||||
json_out_stream << L"\"stream_" << i << L"\": \"";
|
||||
JSONescape(json_out_stream, req.out_streams[i].Str());
|
||||
json_out_stream << L"\",\n";
|
||||
if( !is_first )
|
||||
{
|
||||
json_out_stream << L",\n";
|
||||
}
|
||||
|
||||
json_out_stream << L"\"";
|
||||
JSONescape(json_out_stream, i->first);
|
||||
json_out_stream << L"\": \"";
|
||||
JSONescape(json_out_stream, i->second->Str());
|
||||
json_out_stream << L"\"";
|
||||
is_first = false;
|
||||
}
|
||||
|
||||
json_out_stream << L"\"info\": ";
|
||||
json_out_stream << L"}\n,\n\"info\": ";
|
||||
}
|
||||
|
||||
if( req.info_serializer )
|
||||
@@ -604,7 +615,7 @@ bool sent = false;
|
||||
{
|
||||
if( cur.request->function == &functions.fun_cat )
|
||||
{
|
||||
TemplatesFunctions::item_print_content(cur.request->out_streams[0],
|
||||
TemplatesFunctions::item_print_content(cur.request->out_main_stream,
|
||||
cur.request->item.content, cur.request->item.content_type);
|
||||
sent = true;
|
||||
}
|
||||
@@ -1241,33 +1252,40 @@ void App::FilterContent()
|
||||
req.status == WINIX_ERR_OK && req.function &&
|
||||
(req.function == &functions.fun_cat || req.function == &functions.fun_run);
|
||||
|
||||
size_t start = req.out_streams.size(); // default nothing should be filtered
|
||||
size_t end = req.out_streams.size();
|
||||
bool filter_main_stream = false;
|
||||
bool filter_json = false;
|
||||
|
||||
if( config.html_filter && !req.send_bin_stream && !raw )
|
||||
{
|
||||
if( req.return_json )
|
||||
{
|
||||
if( !req.return_info_only )
|
||||
if( !req.return_info_only && req.out_streams_use_html_filter )
|
||||
{
|
||||
start = 1;
|
||||
filter_json = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0;
|
||||
end = 1;
|
||||
if( req.out_main_stream_use_html_filter )
|
||||
filter_main_stream = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(size_t i=start ; i<end ; ++i)
|
||||
if( filter_main_stream )
|
||||
{
|
||||
if( req.use_html_filter[i] )
|
||||
// !! IMPROVE ME may some kind of html_filtered.reserve() here? (optimization)
|
||||
TemplatesFunctions::html_filter.Filter(req.out_main_stream.Str(), html_filtered);
|
||||
req.out_main_stream.Str(std::move(html_filtered)); // !! IMPROVE ME we do not have Str(&&) method
|
||||
}
|
||||
|
||||
if( filter_json )
|
||||
{
|
||||
for(auto i = req.out_streams.streams_map.begin() ; i != req.out_streams.streams_map.end() ; ++i)
|
||||
{
|
||||
HtmlTextStream & stream = *i->second;
|
||||
// !! IMPROVE ME may some kind of html_filtered.reserve() here? (optimization)
|
||||
TemplatesFunctions::html_filter.Filter(req.out_streams[i].Str(), html_filtered);
|
||||
req.out_streams[i].Str(std::move(html_filtered));
|
||||
TemplatesFunctions::html_filter.Filter(stream.Str(), html_filtered);
|
||||
stream.Str(std::move(html_filtered));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1398,7 +1416,7 @@ size_t output_size = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
source = &cur.request->out_streams[0].Str();
|
||||
source = &cur.request->out_main_stream.Str();
|
||||
}
|
||||
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
|
Reference in New Issue
Block a user