changed the way how the request's answer is created,

now winix can return json, xml, csv from out_main_stream or from frames and json from models

removed from Request:
  bool send_bin_stream
  bool return_json
  bool return_info_only
  pt::Space info
  bool page_generated
  bool out_main_stream_use_html_filter
  bool out_streams_use_html_filter

added to Request:
  enum AnswerSource
  enum AnswerContainer
  AnswerSource answer_source
  AnswerContainer answer_container
  bool use_ezc_engine
  std::wstring frame
  bool send_all_frames
  bool use_html_filter

added to Config:
 // the name of the url parameter for returning all frames, e.g. https://domain.tld/mydir/myfunction/allframes
 // default: allframes
 std::wstring request_all_frames_parameter;

 // the name of the root element when serializing request answer to xml
 // default: winix
 std::wstring xml_root;

algorithm (the whole algorithm is described in core/request.h):
at the beginning of a request winix sets
   answer_source to models
   answer_container to text
   use_ezc_engine to true

next answer_container and use_ezc_engine can be changed in the following way:

1. winix will look for 'Accept' http header and depending on the header winix will set:
   (not implemented yet)

             Accept | answer_container | use_ezc_engine
	     ------------------------------------|-----------------
	     application/json | json             | false
	      application/xml | xml              | false
	              text/csv | csv              | false

2. next answer_container is set depending on 'container' url parameter
       container | answer_container
 ---------------------------------------------------------
     not present | don't change the value
            text | text
            json | json
             xml | xml
             csv | csv

use_ezc_engine is set depending on 'answer' url parameter:
          answer | use_ezc_engine
 ---------------------------------
     not present | don't change the value
            html | true
            data | false

if 'answer' is html then we take into account two more parameters:
 frame: frame_name (empty default) - if set then winix returns this specific frame
 allframes: (if present then winix returns all frames)
master
Tomasz Sowa 2021-10-13 01:27:14 +02:00
parent 3e46c5674c
commit d5ebb7ca12
42 changed files with 1085 additions and 599 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,15 +10,15 @@ acceptbaseparser.o: ../../../pikotools/src/utf8/utf8.h
acceptbaseparser.o: ../../../pikotools/src/textstream/stream.h
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8_templates.h
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8_private.h
acceptbaseparser.o: ../../../pikotools/src/convert/baseparser.h log.h
acceptbaseparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
acceptbaseparser.o: ../../../pikotools/src/convert/baseparser.h
acceptbaseparser.o: ../../../pikotools/src/textstream/textstream.h
acceptbaseparser.o: ../../../pikotools/src/textstream/stream.h
acceptbaseparser.o: ../../../pikotools/src/space/space.h
acceptbaseparser.o: ../../../pikotools/src/date/date.h
acceptbaseparser.o: ../../../pikotools/src/membuffer/membuffer.h
acceptbaseparser.o: ../../../pikotools/src/textstream/types.h filelog.h
acceptbaseparser.o: ../../../winix/winixd/core/synchro.h
acceptbaseparser.o: ../../../pikotools/src/textstream/types.h log.h
acceptbaseparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
acceptbaseparser.o: filelog.h ../../../winix/winixd/core/synchro.h
acceptbaseparser.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
acceptbaseparser.o: ../../../morm/src/model.h
acceptbaseparser.o: ../../../morm/src/modelconnector.h
@ -212,14 +212,14 @@ basethread.o: ../../../pikotools/src/utf8/utf8.h
basethread.o: ../../../pikotools/src/textstream/stream.h
basethread.o: ../../../pikotools/src/utf8/utf8_templates.h
basethread.o: ../../../pikotools/src/utf8/utf8_private.h
basethread.o: ../../../pikotools/src/convert/baseparser.h log.h
basethread.o: logmanipulators.h ../../../pikotools/src/log/log.h
basethread.o: ../../../pikotools/src/convert/baseparser.h
basethread.o: ../../../pikotools/src/textstream/textstream.h
basethread.o: ../../../pikotools/src/textstream/stream.h
basethread.o: ../../../pikotools/src/space/space.h
basethread.o: ../../../pikotools/src/date/date.h
basethread.o: ../../../pikotools/src/membuffer/membuffer.h
basethread.o: ../../../pikotools/src/textstream/types.h filelog.h
basethread.o: ../../../pikotools/src/textstream/types.h log.h
basethread.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
basethread.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
basethread.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
basethread.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -352,14 +352,14 @@ crypt.o: ../../../pikotools/src/utf8/utf8.h
crypt.o: ../../../pikotools/src/textstream/stream.h
crypt.o: ../../../pikotools/src/utf8/utf8_templates.h
crypt.o: ../../../pikotools/src/utf8/utf8_private.h
crypt.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
crypt.o: ../../../pikotools/src/log/log.h
crypt.o: ../../../pikotools/src/convert/baseparser.h
crypt.o: ../../../pikotools/src/textstream/textstream.h
crypt.o: ../../../pikotools/src/textstream/stream.h
crypt.o: ../../../pikotools/src/space/space.h
crypt.o: ../../../pikotools/src/date/date.h
crypt.o: ../../../pikotools/src/membuffer/membuffer.h
crypt.o: ../../../pikotools/src/textstream/types.h filelog.h
crypt.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
crypt.o: ../../../pikotools/src/log/log.h filelog.h
crypt.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
crypt.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
crypt.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -412,14 +412,14 @@ dircontainer.o: ../../../pikotools/src/utf8/utf8.h
dircontainer.o: ../../../pikotools/src/textstream/stream.h
dircontainer.o: ../../../pikotools/src/utf8/utf8_templates.h
dircontainer.o: ../../../pikotools/src/utf8/utf8_private.h
dircontainer.o: ../../../pikotools/src/convert/baseparser.h log.h
dircontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h
dircontainer.o: ../../../pikotools/src/convert/baseparser.h
dircontainer.o: ../../../pikotools/src/textstream/textstream.h
dircontainer.o: ../../../pikotools/src/textstream/stream.h
dircontainer.o: ../../../pikotools/src/space/space.h
dircontainer.o: ../../../pikotools/src/date/date.h
dircontainer.o: ../../../pikotools/src/membuffer/membuffer.h
dircontainer.o: ../../../pikotools/src/textstream/types.h filelog.h
dircontainer.o: ../../../pikotools/src/textstream/types.h log.h
dircontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
dircontainer.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
dircontainer.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
dircontainer.o: ../../../morm/src/modelconnector.h
@ -477,14 +477,14 @@ dirs.o: ../../../pikotools/src/utf8/utf8.h
dirs.o: ../../../pikotools/src/textstream/stream.h
dirs.o: ../../../pikotools/src/utf8/utf8_templates.h
dirs.o: ../../../pikotools/src/utf8/utf8_private.h
dirs.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
dirs.o: ../../../pikotools/src/log/log.h
dirs.o: ../../../pikotools/src/convert/baseparser.h
dirs.o: ../../../pikotools/src/textstream/textstream.h
dirs.o: ../../../pikotools/src/textstream/stream.h
dirs.o: ../../../pikotools/src/space/space.h
dirs.o: ../../../pikotools/src/date/date.h
dirs.o: ../../../pikotools/src/membuffer/membuffer.h
dirs.o: ../../../pikotools/src/textstream/types.h filelog.h
dirs.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
dirs.o: ../../../pikotools/src/log/log.h filelog.h
dirs.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
dirs.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
dirs.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -667,15 +667,15 @@ httpsimpleparser.o: ../../../pikotools/src/utf8/utf8.h
httpsimpleparser.o: ../../../pikotools/src/textstream/stream.h
httpsimpleparser.o: ../../../pikotools/src/utf8/utf8_templates.h
httpsimpleparser.o: ../../../pikotools/src/utf8/utf8_private.h
httpsimpleparser.o: ../../../pikotools/src/convert/baseparser.h log.h
httpsimpleparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
httpsimpleparser.o: ../../../pikotools/src/convert/baseparser.h
httpsimpleparser.o: ../../../pikotools/src/textstream/textstream.h
httpsimpleparser.o: ../../../pikotools/src/textstream/stream.h
httpsimpleparser.o: ../../../pikotools/src/space/space.h
httpsimpleparser.o: ../../../pikotools/src/date/date.h
httpsimpleparser.o: ../../../pikotools/src/membuffer/membuffer.h
httpsimpleparser.o: ../../../pikotools/src/textstream/types.h filelog.h
httpsimpleparser.o: ../../../winix/winixd/core/synchro.h
httpsimpleparser.o: ../../../pikotools/src/textstream/types.h log.h
httpsimpleparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
httpsimpleparser.o: filelog.h ../../../winix/winixd/core/synchro.h
httpsimpleparser.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
httpsimpleparser.o: ../../../morm/src/model.h
httpsimpleparser.o: ../../../morm/src/modelconnector.h
@ -723,14 +723,14 @@ image.o: ../../../pikotools/src/utf8/utf8.h
image.o: ../../../pikotools/src/textstream/stream.h
image.o: ../../../pikotools/src/utf8/utf8_templates.h
image.o: ../../../pikotools/src/utf8/utf8_private.h
image.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
image.o: ../../../pikotools/src/log/log.h
image.o: ../../../pikotools/src/convert/baseparser.h
image.o: ../../../pikotools/src/textstream/textstream.h
image.o: ../../../pikotools/src/textstream/stream.h
image.o: ../../../pikotools/src/space/space.h
image.o: ../../../pikotools/src/date/date.h
image.o: ../../../pikotools/src/membuffer/membuffer.h
image.o: ../../../pikotools/src/textstream/types.h filelog.h
image.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
image.o: ../../../pikotools/src/log/log.h filelog.h
image.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
image.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
image.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -810,15 +810,15 @@ ipbancontainer.o: ../../../pikotools/src/utf8/utf8.h
ipbancontainer.o: ../../../pikotools/src/textstream/stream.h
ipbancontainer.o: ../../../pikotools/src/utf8/utf8_templates.h
ipbancontainer.o: ../../../pikotools/src/utf8/utf8_private.h
ipbancontainer.o: ../../../pikotools/src/convert/baseparser.h log.h
ipbancontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h
ipbancontainer.o: ../../../pikotools/src/convert/baseparser.h
ipbancontainer.o: ../../../pikotools/src/textstream/textstream.h
ipbancontainer.o: ../../../pikotools/src/textstream/stream.h
ipbancontainer.o: ../../../pikotools/src/space/space.h
ipbancontainer.o: ../../../pikotools/src/date/date.h
ipbancontainer.o: ../../../pikotools/src/membuffer/membuffer.h
ipbancontainer.o: ../../../pikotools/src/textstream/types.h filelog.h
ipbancontainer.o: ../../../winix/winixd/core/synchro.h
ipbancontainer.o: ../../../pikotools/src/textstream/types.h log.h
ipbancontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h
ipbancontainer.o: filelog.h ../../../winix/winixd/core/synchro.h
ipbancontainer.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
ipbancontainer.o: ../../../morm/src/model.h
ipbancontainer.o: ../../../morm/src/modelconnector.h
@ -857,14 +857,14 @@ job.o: ../../../pikotools/src/utf8/utf8.h
job.o: ../../../pikotools/src/textstream/stream.h
job.o: ../../../pikotools/src/utf8/utf8_templates.h
job.o: ../../../pikotools/src/utf8/utf8_private.h
job.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
job.o: ../../../pikotools/src/log/log.h
job.o: ../../../pikotools/src/convert/baseparser.h
job.o: ../../../pikotools/src/textstream/textstream.h
job.o: ../../../pikotools/src/textstream/stream.h
job.o: ../../../pikotools/src/space/space.h
job.o: ../../../pikotools/src/date/date.h
job.o: ../../../pikotools/src/membuffer/membuffer.h
job.o: ../../../pikotools/src/textstream/types.h filelog.h
job.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
job.o: ../../../pikotools/src/log/log.h filelog.h
job.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
job.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
job.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -895,13 +895,13 @@ lastcontainer.o: ../../../pikotools/src/utf8/utf8.h
lastcontainer.o: ../../../pikotools/src/textstream/stream.h
lastcontainer.o: ../../../pikotools/src/utf8/utf8_templates.h
lastcontainer.o: ../../../pikotools/src/utf8/utf8_private.h
lastcontainer.o: ../../../pikotools/src/convert/baseparser.h log.h
lastcontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h
lastcontainer.o: ../../../pikotools/src/convert/baseparser.h
lastcontainer.o: ../../../pikotools/src/textstream/textstream.h
lastcontainer.o: ../../../pikotools/src/textstream/stream.h
lastcontainer.o: ../../../pikotools/src/space/space.h
lastcontainer.o: ../../../pikotools/src/membuffer/membuffer.h
lastcontainer.o: ../../../pikotools/src/textstream/types.h filelog.h
lastcontainer.o: ../../../pikotools/src/textstream/types.h log.h
lastcontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
lastcontainer.o: ../../../winix/winixd/core/synchro.h
lastcontainer.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
lastcontainer.o: ../../../morm/src/model.h ../../../morm/src/modelconnector.h
@ -943,14 +943,14 @@ loadavg.o: ../../../pikotools/src/utf8/utf8.h
loadavg.o: ../../../pikotools/src/textstream/stream.h
loadavg.o: ../../../pikotools/src/utf8/utf8_templates.h
loadavg.o: ../../../pikotools/src/utf8/utf8_private.h
loadavg.o: ../../../pikotools/src/convert/baseparser.h log.h
loadavg.o: logmanipulators.h ../../../pikotools/src/log/log.h
loadavg.o: ../../../pikotools/src/convert/baseparser.h
loadavg.o: ../../../pikotools/src/textstream/textstream.h
loadavg.o: ../../../pikotools/src/textstream/stream.h
loadavg.o: ../../../pikotools/src/space/space.h
loadavg.o: ../../../pikotools/src/date/date.h
loadavg.o: ../../../pikotools/src/membuffer/membuffer.h
loadavg.o: ../../../pikotools/src/textstream/types.h filelog.h
loadavg.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
loadavg.o: ../../../pikotools/src/log/log.h filelog.h
loadavg.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
loadavg.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
loadavg.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1138,14 +1138,14 @@ mountparser.o: ../../../pikotools/src/utf8/utf8.h
mountparser.o: ../../../pikotools/src/textstream/stream.h
mountparser.o: ../../../pikotools/src/utf8/utf8_templates.h
mountparser.o: ../../../pikotools/src/utf8/utf8_private.h
mountparser.o: ../../../pikotools/src/convert/baseparser.h log.h
mountparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
mountparser.o: ../../../pikotools/src/convert/baseparser.h
mountparser.o: ../../../pikotools/src/textstream/textstream.h
mountparser.o: ../../../pikotools/src/textstream/stream.h
mountparser.o: ../../../pikotools/src/space/space.h
mountparser.o: ../../../pikotools/src/date/date.h
mountparser.o: ../../../pikotools/src/membuffer/membuffer.h
mountparser.o: ../../../pikotools/src/textstream/types.h filelog.h
mountparser.o: ../../../pikotools/src/textstream/types.h log.h
mountparser.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
mountparser.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
mountparser.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
mountparser.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1217,14 +1217,14 @@ mounts.o: ../../../pikotools/src/utf8/utf8.h
mounts.o: ../../../pikotools/src/textstream/stream.h
mounts.o: ../../../pikotools/src/utf8/utf8_templates.h
mounts.o: ../../../pikotools/src/utf8/utf8_private.h
mounts.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
mounts.o: ../../../pikotools/src/log/log.h
mounts.o: ../../../pikotools/src/convert/baseparser.h
mounts.o: ../../../pikotools/src/textstream/textstream.h
mounts.o: ../../../pikotools/src/textstream/stream.h
mounts.o: ../../../pikotools/src/space/space.h
mounts.o: ../../../pikotools/src/date/date.h
mounts.o: ../../../pikotools/src/membuffer/membuffer.h
mounts.o: ../../../pikotools/src/textstream/types.h filelog.h
mounts.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
mounts.o: ../../../pikotools/src/log/log.h filelog.h
mounts.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
mounts.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
mounts.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1291,14 +1291,14 @@ plugin.o: ../../../pikotools/src/utf8/utf8.h
plugin.o: ../../../pikotools/src/textstream/stream.h
plugin.o: ../../../pikotools/src/utf8/utf8_templates.h
plugin.o: ../../../pikotools/src/utf8/utf8_private.h
plugin.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
plugin.o: ../../../pikotools/src/log/log.h
plugin.o: ../../../pikotools/src/convert/baseparser.h
plugin.o: ../../../pikotools/src/textstream/textstream.h
plugin.o: ../../../pikotools/src/textstream/stream.h
plugin.o: ../../../pikotools/src/space/space.h
plugin.o: ../../../pikotools/src/date/date.h
plugin.o: ../../../pikotools/src/membuffer/membuffer.h
plugin.o: ../../../pikotools/src/textstream/types.h filelog.h
plugin.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
plugin.o: ../../../pikotools/src/log/log.h filelog.h
plugin.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
plugin.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
plugin.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1439,14 +1439,14 @@ plugindata.o: ../../../pikotools/src/utf8/utf8.h
plugindata.o: ../../../pikotools/src/textstream/stream.h
plugindata.o: ../../../pikotools/src/utf8/utf8_templates.h
plugindata.o: ../../../pikotools/src/utf8/utf8_private.h
plugindata.o: ../../../pikotools/src/convert/baseparser.h log.h
plugindata.o: logmanipulators.h ../../../pikotools/src/log/log.h
plugindata.o: ../../../pikotools/src/convert/baseparser.h
plugindata.o: ../../../pikotools/src/textstream/textstream.h
plugindata.o: ../../../pikotools/src/textstream/stream.h
plugindata.o: ../../../pikotools/src/space/space.h
plugindata.o: ../../../pikotools/src/date/date.h
plugindata.o: ../../../pikotools/src/membuffer/membuffer.h
plugindata.o: ../../../pikotools/src/textstream/types.h filelog.h
plugindata.o: ../../../pikotools/src/textstream/types.h log.h
plugindata.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
plugindata.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
plugindata.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
plugindata.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1688,14 +1688,14 @@ run.o: ../../../pikotools/src/utf8/utf8.h
run.o: ../../../pikotools/src/textstream/stream.h
run.o: ../../../pikotools/src/utf8/utf8_templates.h
run.o: ../../../pikotools/src/utf8/utf8_private.h
run.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
run.o: ../../../pikotools/src/log/log.h
run.o: ../../../pikotools/src/convert/baseparser.h
run.o: ../../../pikotools/src/textstream/textstream.h
run.o: ../../../pikotools/src/textstream/stream.h
run.o: ../../../pikotools/src/space/space.h
run.o: ../../../pikotools/src/date/date.h
run.o: ../../../pikotools/src/membuffer/membuffer.h
run.o: ../../../pikotools/src/textstream/types.h filelog.h
run.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
run.o: ../../../pikotools/src/log/log.h filelog.h
run.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
run.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
run.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -1867,14 +1867,14 @@ sessionidmanager.o: ../../../pikotools/src/utf8/utf8.h
sessionidmanager.o: ../../../pikotools/src/textstream/stream.h
sessionidmanager.o: ../../../pikotools/src/utf8/utf8_templates.h
sessionidmanager.o: ../../../pikotools/src/utf8/utf8_private.h
sessionidmanager.o: ../../../pikotools/src/convert/baseparser.h log.h
sessionidmanager.o: logmanipulators.h ../../../pikotools/src/log/log.h
sessionidmanager.o: ../../../pikotools/src/convert/baseparser.h
sessionidmanager.o: ../../../pikotools/src/textstream/textstream.h
sessionidmanager.o: ../../../pikotools/src/textstream/stream.h
sessionidmanager.o: ../../../pikotools/src/date/date.h
sessionidmanager.o: ../../../pikotools/src/membuffer/membuffer.h
sessionidmanager.o: ../../../pikotools/src/textstream/types.h filelog.h
sessionidmanager.o: ../../../winix/winixd/core/synchro.h
sessionidmanager.o: ../../../pikotools/src/textstream/types.h log.h
sessionidmanager.o: logmanipulators.h ../../../pikotools/src/log/log.h
sessionidmanager.o: filelog.h ../../../winix/winixd/core/synchro.h
sessionidmanager.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
sessionidmanager.o: ../../../morm/src/model.h
sessionidmanager.o: ../../../morm/src/modelconnector.h
@ -2176,14 +2176,14 @@ system.o: ../../../pikotools/src/utf8/utf8.h
system.o: ../../../pikotools/src/textstream/stream.h
system.o: ../../../pikotools/src/utf8/utf8_templates.h
system.o: ../../../pikotools/src/utf8/utf8_private.h
system.o: ../../../pikotools/src/convert/baseparser.h log.h logmanipulators.h
system.o: ../../../pikotools/src/log/log.h
system.o: ../../../pikotools/src/convert/baseparser.h
system.o: ../../../pikotools/src/textstream/textstream.h
system.o: ../../../pikotools/src/textstream/stream.h
system.o: ../../../pikotools/src/space/space.h
system.o: ../../../pikotools/src/date/date.h
system.o: ../../../pikotools/src/membuffer/membuffer.h
system.o: ../../../pikotools/src/textstream/types.h filelog.h
system.o: ../../../pikotools/src/textstream/types.h log.h logmanipulators.h
system.o: ../../../pikotools/src/log/log.h filelog.h
system.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
system.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
system.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -2322,14 +2322,14 @@ threadmanager.o: ../../../pikotools/src/utf8/utf8.h
threadmanager.o: ../../../pikotools/src/textstream/stream.h
threadmanager.o: ../../../pikotools/src/utf8/utf8_templates.h
threadmanager.o: ../../../pikotools/src/utf8/utf8_private.h
threadmanager.o: ../../../pikotools/src/convert/baseparser.h log.h
threadmanager.o: logmanipulators.h ../../../pikotools/src/log/log.h
threadmanager.o: ../../../pikotools/src/convert/baseparser.h
threadmanager.o: ../../../pikotools/src/textstream/textstream.h
threadmanager.o: ../../../pikotools/src/textstream/stream.h
threadmanager.o: ../../../pikotools/src/space/space.h
threadmanager.o: ../../../pikotools/src/date/date.h
threadmanager.o: ../../../pikotools/src/membuffer/membuffer.h
threadmanager.o: ../../../pikotools/src/textstream/types.h filelog.h
threadmanager.o: ../../../pikotools/src/textstream/types.h log.h
threadmanager.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
threadmanager.o: ../../../winix/winixd/core/synchro.h
threadmanager.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
threadmanager.o: ../../../morm/src/model.h ../../../morm/src/modelconnector.h
@ -2384,13 +2384,13 @@ timezones.o: ../../../pikotools/src/utf8/utf8.h
timezones.o: ../../../pikotools/src/textstream/stream.h
timezones.o: ../../../pikotools/src/utf8/utf8_templates.h
timezones.o: ../../../pikotools/src/utf8/utf8_private.h
timezones.o: ../../../pikotools/src/convert/baseparser.h winixbase.h
timezones.o: ../../../winix/winixd/core/config.h log.h logmanipulators.h
timezones.o: ../../../pikotools/src/log/log.h
timezones.o: ../../../pikotools/src/convert/baseparser.h
timezones.o: ../../../pikotools/src/textstream/textstream.h
timezones.o: ../../../pikotools/src/textstream/stream.h
timezones.o: ../../../pikotools/src/membuffer/membuffer.h
timezones.o: ../../../pikotools/src/textstream/types.h filelog.h
timezones.o: ../../../pikotools/src/textstream/types.h winixbase.h
timezones.o: ../../../winix/winixd/core/config.h log.h logmanipulators.h
timezones.o: ../../../pikotools/src/log/log.h filelog.h
timezones.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
timezones.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
timezones.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -2518,14 +2518,14 @@ winixbase.o: ../../../pikotools/src/utf8/utf8.h
winixbase.o: ../../../pikotools/src/textstream/stream.h
winixbase.o: ../../../pikotools/src/utf8/utf8_templates.h
winixbase.o: ../../../pikotools/src/utf8/utf8_private.h
winixbase.o: ../../../pikotools/src/convert/baseparser.h log.h
winixbase.o: logmanipulators.h ../../../pikotools/src/log/log.h
winixbase.o: ../../../pikotools/src/convert/baseparser.h
winixbase.o: ../../../pikotools/src/textstream/textstream.h
winixbase.o: ../../../pikotools/src/textstream/stream.h
winixbase.o: ../../../pikotools/src/space/space.h
winixbase.o: ../../../pikotools/src/date/date.h
winixbase.o: ../../../pikotools/src/membuffer/membuffer.h
winixbase.o: ../../../pikotools/src/textstream/types.h filelog.h
winixbase.o: ../../../pikotools/src/textstream/types.h log.h
winixbase.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
winixbase.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
winixbase.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
winixbase.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
@ -2559,15 +2559,15 @@ winixmodeldeprecated.o: ../../../pikotools/src/utf8/utf8.h
winixmodeldeprecated.o: ../../../pikotools/src/textstream/stream.h
winixmodeldeprecated.o: ../../../pikotools/src/utf8/utf8_templates.h
winixmodeldeprecated.o: ../../../pikotools/src/utf8/utf8_private.h
winixmodeldeprecated.o: ../../../pikotools/src/convert/baseparser.h log.h
winixmodeldeprecated.o: logmanipulators.h ../../../pikotools/src/log/log.h
winixmodeldeprecated.o: ../../../pikotools/src/convert/baseparser.h
winixmodeldeprecated.o: ../../../pikotools/src/textstream/textstream.h
winixmodeldeprecated.o: ../../../pikotools/src/textstream/stream.h
winixmodeldeprecated.o: ../../../pikotools/src/space/space.h
winixmodeldeprecated.o: ../../../pikotools/src/date/date.h
winixmodeldeprecated.o: ../../../pikotools/src/membuffer/membuffer.h
winixmodeldeprecated.o: ../../../pikotools/src/textstream/types.h filelog.h
winixmodeldeprecated.o: ../../../winix/winixd/core/synchro.h
winixmodeldeprecated.o: ../../../pikotools/src/textstream/types.h log.h
winixmodeldeprecated.o: logmanipulators.h ../../../pikotools/src/log/log.h
winixmodeldeprecated.o: filelog.h ../../../winix/winixd/core/synchro.h
winixmodeldeprecated.o: ../../../morm/src/morm.h
winixmodeldeprecated.o: ../../../morm/src/morm_types.h
winixmodeldeprecated.o: ../../../morm/src/model.h
@ -2611,14 +2611,14 @@ winixsystem.o: ../../../pikotools/src/utf8/utf8.h
winixsystem.o: ../../../pikotools/src/textstream/stream.h
winixsystem.o: ../../../pikotools/src/utf8/utf8_templates.h
winixsystem.o: ../../../pikotools/src/utf8/utf8_private.h
winixsystem.o: ../../../pikotools/src/convert/baseparser.h log.h
winixsystem.o: logmanipulators.h ../../../pikotools/src/log/log.h
winixsystem.o: ../../../pikotools/src/convert/baseparser.h
winixsystem.o: ../../../pikotools/src/textstream/textstream.h
winixsystem.o: ../../../pikotools/src/textstream/stream.h
winixsystem.o: ../../../pikotools/src/space/space.h
winixsystem.o: ../../../pikotools/src/date/date.h
winixsystem.o: ../../../pikotools/src/membuffer/membuffer.h
winixsystem.o: ../../../pikotools/src/textstream/types.h filelog.h
winixsystem.o: ../../../pikotools/src/textstream/types.h log.h
winixsystem.o: logmanipulators.h ../../../pikotools/src/log/log.h filelog.h
winixsystem.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
winixsystem.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
winixsystem.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h

View File

@ -711,8 +711,9 @@ void App::ClearAfterRequest()
cur.session->ClearAfterRequest();
cur.session = session_manager.GetTmpSession();
output_8bit.clear();
output_8bit2.clear();
compressed_output.clear();
html_filtered.clear();
//html_filtered.clear();
aheader_name.clear();
aheader_value.clear();
cur.mount = system.mounts.GetEmptyMount();
@ -775,77 +776,11 @@ void App::SaveSessionsIfNeeded()
}
pt::WTextStream * App::CreateFrameAnswer()
{
Request & req = *cur.request;
auto i = req.out_streams.streams_map.begin();
const std::wstring * frame = cur.request->ParamValuep(config.request_frame_parameter);
if( frame )
{
for( ; i != req.out_streams.streams_map.end() ; ++i)
{
if( i->first == *frame )
{
return &i->second->get_buffer();
}
}
}
return nullptr;
}
pt::WTextStream * App::CreateJSONAnswer()
{
Request & req = *cur.request;
json_out_stream.clear();
if( !req.return_info_only )
{
json_out_stream << L"{\n\"frames\": {\n";
auto i = req.out_streams.streams_map.begin();
bool is_first = true;
for( ; i != req.out_streams.streams_map.end() ; ++i)
{
if( !is_first )
{
json_out_stream << L",\n";
}
json_out_stream << L"\"";
JSONescape(i->first, json_out_stream);
json_out_stream << L"\": \"";
JSONescapeStream(i->second->get_buffer(), json_out_stream);
json_out_stream << L"\"";
is_first = false;
}
json_out_stream << L"}\n,\n\"info\": ";
}
req.info.serialize_to_json_stream(json_out_stream, false);
log << log3 << "App: sending JSON answer";
if( !req.return_info_only )
json_out_stream << L"}\n";
else
log << " (Request::info only)";
log << logend;
return &json_out_stream;
}
// !! IMPROVE ME change to a better name
void App::MakePage()
void App::MakeEzcGenerator()
{
if( cur.request->page_generated || !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
return;
// if( cur.request->page_generated || !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
// return;
clock_gettime(CLOCK_REALTIME, &cur.request->timespec_ezc_engine_start);
@ -888,10 +823,12 @@ void App::CheckPostRedirect()
void App::AddDefaultModels()
{
if( !cur.request->send_bin_stream && !cur.request->return_json )
// there is no need to add default models if we return a binary stream
if( cur.request->answer_source != Request::AnswerSource::answer_bin_stream )
{
if( cur.request->function && cur.request->function->register_default_models )
{
// may it would be better do not return cur.request by default?
cur.request->models.Add(L"request", cur.request);
if( cur.session && cur.session->puser )
@ -920,8 +857,8 @@ void App::Make()
return;
}
if( cur.request->ParamValue(L"reqtype") == L"json" )
cur.request->return_json = true;
if( !cur.request->PrepareAnswerType() )
return;
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{
@ -973,9 +910,6 @@ void App::Make()
log << log1 << "App: there is no a root dir (dir_tab is empty -- after calling a function)" << logend;
return;
}
plugin.Call(WINIX_CONTENT_MAKE);
MakePage();
}
@ -1316,9 +1250,9 @@ void App::ReadPostVars()
post_multi_parser.Parse(fcgi_request.in, cur.request->post_tab, cur.request->post_file_tab);
}
else
if( pt::is_substr_nc(L"application/json", cur.request->env_content_type.c_str()) )
if( pt::is_substr_nc(Winix::Header::application_json, cur.request->env_content_type.c_str()) )
{
log << log3 << "App: post content type: application/json" << logend;
log << log3 << "App: post content type: " << Winix::Header::application_json << logend;
ReadPostJson();
}
else
@ -1498,27 +1432,42 @@ void App::PrepareHeaderContentType()
{
if( !cur.request->out_headers.has_key(Winix::Header::content_type) )
{
if( !cur.request->send_bin_stream )
if( cur.request->answer_source == Request::AnswerSource::answer_bin_stream )
{
if( cur.request->return_json )
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::application_octet_stream);
}
else
{
if( cur.request->answer_container == Request::AnswerContainer::answer_json )
{
cur.request->out_headers.add(Winix::Header::content_type, L"application/json; charset=UTF-8");
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::application_json_utf8);
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
{
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::application_xml_utf8);
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_csv )
{
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::text_csv_utf8);
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_text )
{
switch( config.content_type_header )
{
case 1:
cur.request->out_headers.add(Winix::Header::content_type, L"application/xhtml+xml; charset=UTF-8");
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::application_xhtml_xml_utf8);
break;
case 2:
cur.request->out_headers.add(Winix::Header::content_type, L"application/xml; charset=UTF-8");
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::application_xml_utf8);
break;
case 0:
default:
cur.request->out_headers.add(Winix::Header::content_type, L"text/html; charset=UTF-8");
cur.request->out_headers.add(Winix::Header::content_type, Winix::Header::text_html_utf8);
}
}
}
@ -1689,7 +1638,8 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
if( cur.request->send_as_attachment )
AddHeader(L"Content-Disposition", L"attachment");
if( !cur.request->redirect_to.empty() && !cur.request->return_json )
//if( !cur.request->redirect_to.empty() && !cur.request->return_json )
if( !cur.request->redirect_to.empty() )
{
PrepareHeadersRedirect();
}
@ -1713,82 +1663,6 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
}
void App::PrepareStandardJSONFields()
{
pt::Space & info = cur.request->info;
if( !info.has_key(L"status") )
{
info.add(L"status", cur.request->status);
}
if( !cur.request->redirect_to.empty() && !info.has_key(L"redirect_to") )
{
info.add(L"redirect_to", cur.request->redirect_to);
}
}
void App::FilterContent()
{
Request & req = *cur.request;
bool filter_main_stream = false;
bool filter_json = false;
if( config.html_filter && !req.send_bin_stream )
{
if( req.return_json )
{
if( !req.return_info_only && req.out_streams_use_html_filter )
{
filter_json = true;
}
}
else
{
if( req.out_main_stream_use_html_filter )
filter_main_stream = true;
}
}
if( filter_main_stream )
{
std::wstring tmp_out_main_stream;
req.out_main_stream.to_str(tmp_out_main_stream, false);
TemplatesFunctions::html_filter.Filter(tmp_out_main_stream, html_filtered); // IMPROVEME let Filter take pt::WTextStream
/*
* it would be better to just return a pointer from this method
*
*/
req.out_main_stream.clear();
req.out_main_stream.PutText(html_filtered);
log << log3 << "App: html in the main stream has been filtered" << logend;
}
if( filter_json )
{
for(auto i = req.out_streams.streams_map.begin() ; i != req.out_streams.streams_map.end() ; ++i)
{
HtmlTextStream & stream = *i->second;
std::wstring tmp_stream;
stream.to_str(tmp_stream, false);
TemplatesFunctions::html_filter.Filter(tmp_stream, html_filtered);
stream.clear();
stream.PutText(html_filtered);
}
log << log3 << "App: html in json out streams have been filtered" << logend;
}
}
int App::SelectDeflateVersion()
@ -1856,11 +1730,11 @@ bool App::CanSendContent()
return false;
}
if( cur.request->return_json )
{
// if there is a redirect flag then it will be put to info struct
return true;
}
// if( cur.request->return_json )
// {
// // if there is a redirect flag then it will be put to info struct
// return true;
// }
if( !cur.request->redirect_to.empty() )
{
@ -1918,79 +1792,9 @@ bool App::IsRequestedFrame()
}
void App::SendTextAnswer()
{
const pt::WTextStream * source = nullptr;
bool compressing = false;
int compress_encoding = 0;
size_t output_size = 0;
Header header = GetHTTPStatusCode();
if( CanSendContent() )
{
/*
* FIXME frames are not filtered (when is_htmx_request is true)
*
* FilterContent() should be combined with CreateJSONAnswer() and CreateFrameAnswer() somehow
*/
FilterContent();
// cur.request->return_json is depracated, we will create json from models/space registered through request->models object
if( cur.request->return_json )
{
source = CreateJSONAnswer();
}
else
if( IsRequestedFrame() )
{
source = CreateFrameAnswer();
if( !source )
{
empty_response.clear();
source = &empty_response;
}
}
else
{
source = &cur.request->out_main_stream.get_buffer();
}
SelectCompression(source->size(), compressing, compress_encoding);
pt::wide_stream_to_utf8(*source, output_8bit);
// !! IMPROVE ME add to log the binary stream as well
if( config.log_server_answer )
log << log1 << "App: the server's answer is:\n" << output_8bit << "\nApp: end of the server's answer" << logend;
if( compressing )
{
compress.Compressing(output_8bit.c_str(), output_8bit.length(), compressed_output, compress_encoding);
output_size = compressed_output.size();
}
else
{
output_size = output_8bit.size();
}
}
PrepareHeaders(compressing, compress_encoding, header, output_size);
SendHeaders();
SendCookies();
FCGX_PutS("\r\n", fcgi_request.out);
if( CanSendContent() )
{
if( compressing )
SendData(compressed_output, fcgi_request.out);
else
FCGX_PutStr(output_8bit.c_str(), output_8bit.size(), fcgi_request.out);
}
}
// IMPROVEME
// we can send directly from BinaryPage without copying to a temporary buffer
// (but there is no an interface in BinaryPage yet)
void App::SendData(const BinaryPage & page, FCGX_Stream * out)
{
const size_t buf_size = 4096;
@ -2014,28 +1818,410 @@ void App::SendData(const BinaryPage & page, FCGX_Stream * out)
}
void App::SendBinaryAnswer()
void App::SendAnswer()
{
BinaryPage & source = cur.request->out_bin_stream;
Header header = h_200;
Error status = cur.request->status;
bool compressing;
int compress_encoding;
output_8bit.clear();
output_8bit2.clear();
compressed_output.clear();
SelectCompression(source.size(), compressing, compress_encoding);
// may use CanSendContent() method?
// what about method HEAD?
if( !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
{
Send8bitOutput(output_8bit);
return;
}
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
header = h_404;
if( cur.request->answer_source == Request::AnswerSource::answer_bin_stream )
{
Send8bitOutput(cur.request->out_bin_stream);
}
else
{
// is this plugin call correct here?
plugin.Call(WINIX_CONTENT_MAKE);
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
header = h_403;
if( cur.request->answer_source == Request::AnswerSource::answer_models && cur.request->use_ezc_engine )
{
MakeEzcGenerator(); // give me a better name
if( !cur.request->frame.empty() || cur.request->send_all_frames )
{
cur.request->answer_source = Request::AnswerSource::answer_frame_streams;
}
else
{
cur.request->answer_source = Request::AnswerSource::answer_main_stream;
}
}
if( cur.request->answer_source == Request::AnswerSource::answer_main_stream )
{
const wchar_t * field_name = nullptr;
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
field_name = config.xml_root.c_str();
SerializeStream(cur.request->out_main_stream.get_buffer(), field_name);
}
else
if( cur.request->answer_source == Request::AnswerSource::answer_frame_streams )
{
SerializeFrames();
}
else
if( cur.request->answer_source == Request::AnswerSource::answer_models )
{
SerializeModels();
}
Send8bitOutput(output_8bit);
}
}
// !! IMPROVE ME add header: content-length (size from Item struct)
// warning: if someone changed a file on the disk (in the real os)
// then winix would send an incorrect content-lenght header,
// we are waiting for the fsck winix function to be implemented
PrepareHeaders(compressing, compress_encoding, header, static_cast<size_t>(-1));
void App::SerializeStream(const pt::WTextStream & input_stream, const wchar_t * field_name)
{
switch( cur.request->answer_container )
{
case Request::AnswerContainer::answer_json:
SerializeStreamJson(input_stream, field_name);
break;
case Request::AnswerContainer::answer_xml:
SerializeStreamXml(input_stream, field_name);
break;
case Request::AnswerContainer::answer_csv:
SerializeStreamCsv(input_stream, field_name);
break;
case Request::AnswerContainer::answer_text:
default:
FilterHtmlIfNeeded(input_stream, output_8bit);
break;
}
}
void App::SerializeStreamJson(const pt::WTextStream & input_stream, const wchar_t * field_name)
{
if( field_name )
{
output_8bit << '"';
pt::esc_to_json(field_name, output_8bit);
output_8bit << "\":";
}
output_8bit << '"';
FilterHtmlIfNeeded(input_stream, output_8bit2);
pt::esc_to_json(output_8bit2, output_8bit);
output_8bit << '"';
}
void App::SerializeStreamXml(const pt::WTextStream & input_stream, const wchar_t * field_name)
{
if( field_name )
{
output_8bit << '<';
pt::esc_to_xml(field_name, output_8bit);
output_8bit << '>';
}
FilterHtmlIfNeeded(input_stream, output_8bit2);
pt::esc_to_xml(output_8bit2, output_8bit);
if( field_name )
{
output_8bit << "</";
pt::esc_to_xml(field_name, output_8bit);
output_8bit << '>';
}
}
void App::SerializeStreamCsv(const pt::WTextStream & input_stream, const wchar_t * field_name)
{
if( field_name )
{
output_8bit << '"';
pt::esc_to_csv(field_name, output_8bit);
output_8bit << "\";";
}
FilterHtmlIfNeeded(input_stream, output_8bit2);
output_8bit << '"';
pt::esc_to_csv(output_8bit2, output_8bit);
output_8bit << "\";\n";
}
void App::SerializeFrames()
{
if( cur.request->answer_container == Request::AnswerContainer::answer_json )
{
output_8bit << '{';
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
{
output_8bit << '<';
pt::esc_to_xml(config.xml_root, output_8bit);
output_8bit << '>';
}
if( cur.request->frame.empty() || cur.request->send_all_frames )
SerializeAllFrames();
else
SerializeOneFrame();
if( cur.request->answer_container == Request::AnswerContainer::answer_json )
{
output_8bit << '}';
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
{
output_8bit << "</";
pt::esc_to_xml(config.xml_root, output_8bit);
output_8bit << '>';
}
}
void App::SerializeAllFrames()
{
auto i = cur.request->out_streams.streams_map.begin();
bool is_first = true;
for( ; i != cur.request->out_streams.streams_map.end() ; ++i)
{
if( cur.request->answer_container == Request::AnswerContainer::answer_json && !is_first )
{
output_8bit << ',';
}
if( cur.request->answer_container == Request::AnswerContainer::answer_xml && i->first.empty() )
{
log << log2 << "App: I cannot serialize a frame with an empty name to xml (frame skipped)" << logend;
}
else
{
SerializeStream(i->second->get_buffer(), i->first.c_str());
}
is_first = false;
}
}
void App::SerializeOneFrame()
{
auto i = cur.request->out_streams.streams_map.find(cur.request->frame);
if( i != cur.request->out_streams.streams_map.end() )
{
SerializeStream(i->second->get_buffer(), cur.request->frame.c_str());
}
else
{
log << log2 << "App: there is no such a frame: " << cur.request->frame << logend;
// return 404 in such a case?
}
}
void App::SerializeModels()
{
Ezc::Models::ModelsMap models_map = cur.request->models.GetMap();
auto i = models_map.begin();
if( cur.request->answer_container == Request::AnswerContainer::answer_json )
{
output_8bit << '{';
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
{
output_8bit << '<';
pt::esc_to_xml(config.xml_root, output_8bit);
output_8bit << '>';
log << log2 << "App: serializing models to xml not implemented yet" << logend;
}
bool is_first = true;
for( ; i != models_map.end() ; ++i)
{
if( cur.request->answer_container == Request::AnswerContainer::answer_json && !is_first )
{
output_8bit << ',';
}
if( cur.request->answer_container == Request::AnswerContainer::answer_xml && i->first.empty() )
{
log << log2 << "App: I cannot serialize a model with an empty name to xml (model skipped)" << logend;
}
else
{
SerializeModel(i->second, i->first.c_str());
}
is_first = false;
}
if( cur.request->answer_container == Request::AnswerContainer::answer_json )
{
output_8bit << '}';
}
else
if( cur.request->answer_container == Request::AnswerContainer::answer_xml )
{
output_8bit << "</";
pt::esc_to_xml(config.xml_root, output_8bit);
output_8bit << '>';
}
}
void App::SerializeModel(morm::Wrapper & wrapper, const wchar_t * field_name)
{
switch( cur.request->answer_container )
{
case Request::AnswerContainer::answer_json:
SerializeModelJson(wrapper, field_name);
break;
case Request::AnswerContainer::answer_xml:
SerializeModelXml(wrapper, field_name);
break;
case Request::AnswerContainer::answer_csv:
SerializeModelCsv(wrapper, field_name);
break;
case Request::AnswerContainer::answer_text:
default:
SerializeModelCsv(wrapper, field_name);
break;
}
}
void App::SerializeModelJson(morm::Wrapper & wrapper, const wchar_t * field_name)
{
if( field_name )
{
output_8bit << '"';
pt::esc_to_json(field_name, output_8bit);
output_8bit << "\":";
}
if( wrapper.model )
{
serialized_model.clear();
wrapper.model->set_connector(model_connector);
wrapper.model->to_text(serialized_model);
output_8bit << serialized_model;
}
if( wrapper.date )
{
output_8bit << '"';
wrapper.date->SerializeISO(output_8bit);
output_8bit << '"';
}
if( wrapper.space_wrapper )
{
wrapper.space_wrapper->get_space()->serialize_to_json_stream(output_8bit, false);
}
if( wrapper.model_container_wrapper )
{
wrapper.model_container_wrapper->set_iterator_at_first_model();
bool is_first = true;
output_8bit << '[';
while( wrapper.model_container_wrapper->is_iterator_correct() )
{
if( !is_first )
output_8bit << ',';
morm::Model * model = wrapper.model_container_wrapper->get_model();
serialized_model.clear();
model->set_connector(model_connector);
model->to_text(serialized_model);
output_8bit << serialized_model;
wrapper.model_container_wrapper->increment_iterator();
is_first = false;
}
output_8bit << ']';
}
}
void App::SerializeModelXml(morm::Wrapper & wrapper, const wchar_t * field_name)
{
// IMPROVEME
log << log2 << "App: serializing models to xml not implemented yet" << logend;
}
void App::SerializeModelCsv(morm::Wrapper & wrapper, const wchar_t * field_name)
{
// IMPROVEME
log << log2 << "App: serializing models to csv not implemented yet" << logend;
}
// IMPROVEME
// gime me a better name
void App::FilterHtmlIfNeeded(const pt::WTextStream & input_stream, BinaryPage & output, bool clear_stream)
{
if( config.html_filter && cur.request->use_html_filter )
{
TemplatesFunctions::html_filter.filter(input_stream, output, clear_stream);
}
else
{
pt::wide_stream_to_utf8(input_stream, output, clear_stream);
}
}
void App::Send8bitOutput(BinaryPage & output)
{
bool compressing = false;
int compress_encoding = 0;
Header header = GetHTTPStatusCode();
size_t output_size = 0;
SelectCompression(output.size(), compressing, compress_encoding);
if( config.log_server_answer )
{
log << log1 << "App: the server's answer is:\n" << output << "\nApp: end of the server's answer" << logend;
}
if( compressing )
{
compress.Compressing(output, compressed_output, compress_encoding);
output_size = compressed_output.size();
}
else
{
output_size = output.size();
}
PrepareHeaders(compressing, compress_encoding, header, output_size);
SendHeaders();
SendCookies();
FCGX_PutS("\r\n", fcgi_request.out);
@ -2043,29 +2229,13 @@ int compress_encoding;
if( CanSendContent() )
{
if( compressing )
{
compress.Compressing(source, compressed_output, compress_encoding);
SendData(compressed_output, fcgi_request.out);
}
else
{
SendData(source, fcgi_request.out);
}
SendData(output, fcgi_request.out);
}
}
void App::SendAnswer()
{
if( cur.request->return_json )
PrepareStandardJSONFields();
if( cur.request->send_bin_stream )
SendBinaryAnswer();
else
SendTextAnswer();
}
void App::LogUser(const char * msg, uid_t id)
{

View File

@ -149,9 +149,13 @@ private:
std::string send_data_buf;
pt::WTextStream json_out_stream;
std::string aheader_name, aheader_value;
std::wstring html_filtered;
std::string output_8bit;
//std::wstring html_filtered;
//std::string output_8bit;
pt::TextStream serialized_model;
BinaryPage output_8bit, output_8bit2;
BinaryPage compressed_output;
std::wstring cookie_id_string;
std::wstring http_header_name;
std::wstring http_header_value;
@ -194,19 +198,32 @@ private:
void CheckIfNeedSSLredirect();
void SetLocale();
void CheckPostRedirect();
void MakePage();
void MakeEzcGenerator();
void AddDefaultModels();
void Make();
void SaveSessionsIfNeeded(); // !! IMPROVE ME wywalic do menagera sesji??
void LogAccess();
void SendData(const BinaryPage & page, FCGX_Stream * out);
pt::WTextStream * CreateFrameAnswer();
pt::WTextStream * CreateJSONAnswer();
void ReadRequest();
void SendTextAnswer();
void SendBinaryAnswer();
void SendAnswer();
void SerializeStream(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamJson(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamXml(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamCsv(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeFrames();
void SerializeAllFrames();
void SerializeOneFrame();
void SerializeModels();
void Send8bitOutput(BinaryPage & output);
void SerializeModel(morm::Wrapper & wrapper, const wchar_t * field_name);
void SerializeModelJson(morm::Wrapper & wrapper, const wchar_t * field_name);
void SerializeModelXml(morm::Wrapper & wrapper, const wchar_t * field_name);
void SerializeModelCsv(morm::Wrapper & wrapper, const wchar_t * field_name);
void FilterHtmlIfNeeded(const pt::WTextStream & input_stream, BinaryPage & output, bool clear_stream = true);
void LogEnvironmentVariables();
void LogEnvironmentHTTPVariables();
@ -230,7 +247,6 @@ private:
Header GetHTTPStatusCode();
void PrepareSessionCookie();
void FilterContent();
void SendHeaders();
void SendCookies();
bool AddHeader(const wchar_t * name, const wchar_t * value);
@ -246,7 +262,6 @@ private:
void PrepareHeadersCompression(int compress_encoding);
void PrepareHeadersNormal(Header header, size_t output_size