Browse Source

remove Request::post_tab and add Request::http_status

Instead of Reqest::post_tab we use now Request::post_in (pt::Space).

Request::http_status will be used instead Request::status,
but at the moment is not changed in all places.
Request::status has been marked as depracated.

While here:
- Check for root dir in App and not in FunctionParser,
let FunctionParser only log the root dir.
- Read post variables after parsing url parameters,
this allows winix functions to set limits
for post input.
- Set limits when parsing input json format, new
options added to config: post_max_object_items, post_max_table_items,
post_max_all_items, post_max_nested_objects.
There are similar options in each winix function (they are in
FunctionBase).
- Some refactoring in App.
- Add config option: log_whole_http_post if true
then the whole parsed post input is logged.
- Add config option: post_json_max - max length of input stream
for parsing json.
- Add config option: templates_request_status, default request_status.html
this is an ezc template used as [content] when the request status
is not 200_ok.
- Fix: Sort winix function didn't show items to sort (fix and do some
refactoring as well)
- Properly sort items in: ImgCrop, Ls, Sort, Upload
- Remove ezc templates: err_404.html, err_per_denied.html - now
request_status.html is used.
master
Tomasz Sowa 2 months ago
parent
commit
7d1fb3c04e
  1. 2
      winixd/Makefile.dep
  2. 160
      winixd/core/Makefile.dep
  3. 2
      winixd/core/Makefile.o.dep
  4. 538
      winixd/core/app.cpp
  5. 33
      winixd/core/app.h
  6. 14
      winixd/core/config.cpp
  7. 42
      winixd/core/config.h
  8. 74
      winixd/core/header.cpp
  9. 55
      winixd/core/header.h
  10. 23
      winixd/core/postmultiparser.cpp
  11. 11
      winixd/core/postmultiparser.h
  12. 26
      winixd/core/postparser.h
  13. 181
      winixd/core/request.cpp
  14. 18
      winixd/core/request.h
  15. 10
      winixd/core/requesttypes.h
  16. 7
      winixd/db/Makefile.dep
  17. 112
      winixd/functions/Makefile.dep
  18. 6
      winixd/functions/functionbase.cpp
  19. 18
      winixd/functions/functionbase.h
  20. 198
      winixd/functions/functionparser.cpp
  21. 11
      winixd/functions/functionparser.h
  22. 9
      winixd/functions/functions.cpp
  23. 2
      winixd/functions/functions.h
  24. 3
      winixd/functions/imgcrop.cpp
  25. 3
      winixd/functions/ls.cpp
  26. 113
      winixd/functions/sort.cpp
  27. 28
      winixd/functions/sort.h
  28. 10
      winixd/functions/upload.cpp
  29. 3
      winixd/functions/upload.h
  30. 7
      winixd/html/err_404.html
  31. 4
      winixd/html/request_status.html
  32. 25
      winixd/locale/en
  33. 21
      winixd/locale/pl
  34. 13
      winixd/models/Makefile.dep
  35. 5
      winixd/notify/Makefile.dep
  36. 4
      winixd/plugins/gallery/Makefile.dep
  37. 4
      winixd/plugins/group/Makefile.dep
  38. 3
      winixd/plugins/menu/Makefile.dep
  39. 3
      winixd/plugins/stats/Makefile.dep
  40. 9
      winixd/plugins/thread/Makefile.dep
  41. 9
      winixd/plugins/ticket/Makefile.dep
  42. 36
      winixd/plugins/ticket/ticketinfo.cpp
  43. 80
      winixd/templates/Makefile.dep
  44. 74
      winixd/templates/templates.cpp
  45. 3
      winixd/templates/templates.h
  46. 1
      winixd/utils/Makefile.dep

2
winixd/Makefile.dep

File diff suppressed because one or more lines are too long

160
winixd/core/Makefile.dep

@ -42,8 +42,9 @@ app.o: ../../../morm/src/postgresqlexpression.h
app.o: ../../../morm/src/jsonconnector.h
app.o: ../../../morm/src/postgresqlconnector.h
app.o: ../../../morm/src/postgresqlqueryresult.h
app.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/filelog.h
app.o: lock.h synchro.h ../../../pikotools/src/convert/patternreplacer.h
app.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
app.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
app.o: ../../../pikotools/src/convert/patternreplacer.h
app.o: ../../../pikotools/src/convert/strtoint.h
app.o: ../../../pikotools/src/convert/text.h misc.h requesttypes.h
app.o: winix_const.h ../../../pikotools/src/convert/convert.h
@ -191,6 +192,7 @@ basethread.o: ../../../morm/src/postgresqlexpression.h
basethread.o: ../../../morm/src/jsonconnector.h
basethread.o: ../../../morm/src/postgresqlconnector.h
basethread.o: ../../../morm/src/postgresqlqueryresult.h
basethread.o: ../../../morm/src/transaction.h
basethread.o: ../../../winix/winixd/core/log.h
basethread.o: ../../../winix/winixd/core/filelog.h lock.h plugin.h
basethread.o: pluginmsg.h plugindata.h winixbase.h
@ -229,6 +231,7 @@ compress.o: ../../../morm/src/postgresqlexpression.h
compress.o: ../../../morm/src/jsonconnector.h
compress.o: ../../../morm/src/postgresqlconnector.h
compress.o: ../../../morm/src/postgresqlqueryresult.h
compress.o: ../../../morm/src/transaction.h
config.o: config.h log.h logmanipulators.h ../../../pikotools/src/log/log.h
config.o: ../../../pikotools/src/textstream/textstream.h
config.o: ../../../pikotools/src/textstream/stream.h
@ -261,8 +264,9 @@ config.o: ../../../morm/src/cursor.h ../../../morm/src/jsonexpression.h
config.o: ../../../morm/src/postgresqlexpression.h
config.o: ../../../morm/src/jsonconnector.h
config.o: ../../../morm/src/postgresqlconnector.h
config.o: ../../../morm/src/postgresqlqueryresult.h misc.h requesttypes.h
config.o: winix_const.h ../../../pikotools/src/convert/convert.h
config.o: ../../../morm/src/postgresqlqueryresult.h
config.o: ../../../morm/src/transaction.h misc.h requesttypes.h winix_const.h
config.o: ../../../pikotools/src/convert/convert.h
config.o: ../../../pikotools/src/convert/inttostr.h
config.o: ../../../pikotools/src/convert/patternreplacer.h
config.o: ../../../pikotools/src/convert/strtoint.h
@ -333,7 +337,7 @@ crypt.o: ../../../morm/src/postgresqlexpression.h
crypt.o: ../../../morm/src/jsonconnector.h
crypt.o: ../../../morm/src/postgresqlconnector.h
crypt.o: ../../../morm/src/postgresqlqueryresult.h
crypt.o: ../../../winix/winixd/core/log.h
crypt.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
crypt.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
crypt.o: ../../../pikotools/src/convert/patternreplacer.h
crypt.o: ../../../pikotools/src/convert/strtoint.h
@ -405,6 +409,7 @@ dircontainer.o: ../../../morm/src/postgresqlexpression.h
dircontainer.o: ../../../morm/src/jsonconnector.h
dircontainer.o: ../../../morm/src/postgresqlconnector.h
dircontainer.o: ../../../morm/src/postgresqlqueryresult.h
dircontainer.o: ../../../morm/src/transaction.h
dircontainer.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
dircontainer.o: ../../../pikotools/src/convert/patternreplacer.h
dircontainer.o: ../../../pikotools/src/convert/strtoint.h
@ -467,8 +472,8 @@ dirs.o: ../../../morm/src/postgresqlexpression.h
dirs.o: ../../../morm/src/jsonconnector.h
dirs.o: ../../../morm/src/postgresqlconnector.h
dirs.o: ../../../morm/src/postgresqlqueryresult.h
dirs.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
dirs.o: ../../../pikotools/src/convert/patternreplacer.h
dirs.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/filelog.h
dirs.o: lock.h synchro.h ../../../pikotools/src/convert/patternreplacer.h
dirs.o: ../../../pikotools/src/convert/strtoint.h
dirs.o: ../../../pikotools/src/convert/text.h misc.h requesttypes.h
dirs.o: winix_const.h ../../../pikotools/src/convert/convert.h
@ -565,7 +570,7 @@ groups.o: ../../../morm/src/postgresqlexpression.h
groups.o: ../../../morm/src/jsonconnector.h
groups.o: ../../../morm/src/postgresqlconnector.h
groups.o: ../../../morm/src/postgresqlqueryresult.h
groups.o: ../../../winix/winixd/core/log.h
groups.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
groups.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
groups.o: ../../../winix/winixd/core/error.h
groups.o: ../../../winix/winixd/models/user.h
@ -591,6 +596,40 @@ groups.o: ../../../winix/winixd/models/winixmodelconnector.h
groups.o: ../../../winix/winixd/core/dircontainer.h
groups.o: ../../../winix/winixd/core/ugcontainer.h winixbase.h
groups.o: winixmodeldeprecated.h plugin.h pluginmsg.h plugindata.h
header.o: header.h log.h logmanipulators.h ../../../pikotools/src/log/log.h
header.o: ../../../pikotools/src/textstream/textstream.h
header.o: ../../../pikotools/src/textstream/stream.h
header.o: ../../../pikotools/src/space/space.h
header.o: ../../../pikotools/src/textstream/types.h
header.o: ../../../pikotools/src/convert/inttostr.h
header.o: ../../../pikotools/src/utf8/utf8.h
header.o: ../../../pikotools/src/textstream/stream.h
header.o: ../../../pikotools/src/utf8/utf8_templates.h
header.o: ../../../pikotools/src/utf8/utf8_private.h
header.o: ../../../pikotools/src/date/date.h
header.o: ../../../pikotools/src/membuffer/membuffer.h
header.o: ../../../pikotools/src/textstream/types.h
header.o: ../../../pikotools/src/utf8/utf8_stream.h filelog.h
header.o: ../../../winix/winixd/core/synchro.h ../../../morm/src/morm.h
header.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
header.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
header.o: ../../../morm/src/ft.h ../../../morm/src/dbconnector.h
header.o: ../../../morm/src/queryresult.h ../../../morm/src/flatconnector.h
header.o: ../../../morm/src/dbexpression.h ../../../morm/src/baseexpression.h
header.o: ../../../morm/src/modelenv.h ../../../morm/src/modeldata.h
header.o: ../../../morm/src/cursorhelper.h ../../../morm/src/finderhelper.h
header.o: ../../../morm/src/fieldvaluehelper.h ../../../morm/src/wrapper.h
header.o: ../../../morm/src/spacewrapper.h
header.o: ../../../morm/src/baseobjectwrapper.h
header.o: ../../../morm/src/modelcontainerwrapper.h
header.o: ../../../pikotools/src/convert/text.h
header.o: ../../../morm/src/flatexpression.h ../../../morm/src/finder.h
header.o: ../../../morm/src/cursor.h ../../../morm/src/jsonexpression.h
header.o: ../../../morm/src/postgresqlexpression.h
header.o: ../../../morm/src/jsonconnector.h
header.o: ../../../morm/src/postgresqlconnector.h
header.o: ../../../morm/src/postgresqlqueryresult.h
header.o: ../../../morm/src/transaction.h
httpsimpleparser.o: httpsimpleparser.h winixmodeldeprecated.h
httpsimpleparser.o: ../../../winix/winixd/core/winixbase.h
httpsimpleparser.o: ../../../winix/winixd/core/config.h
@ -638,6 +677,7 @@ httpsimpleparser.o: ../../../morm/src/postgresqlexpression.h
httpsimpleparser.o: ../../../morm/src/jsonconnector.h
httpsimpleparser.o: ../../../morm/src/postgresqlconnector.h
httpsimpleparser.o: ../../../morm/src/postgresqlqueryresult.h
httpsimpleparser.o: ../../../morm/src/transaction.h
httpsimpleparser.o: ../../../winix/winixd/core/log.h
httpsimpleparser.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
httpsimpleparser.o: plugin.h pluginmsg.h plugindata.h winixbase.h misc.h
@ -687,7 +727,7 @@ image.o: ../../../morm/src/postgresqlexpression.h
image.o: ../../../morm/src/jsonconnector.h
image.o: ../../../morm/src/postgresqlconnector.h
image.o: ../../../morm/src/postgresqlqueryresult.h
image.o: ../../../winix/winixd/core/log.h
image.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
image.o: ../../../winix/winixd/core/filelog.h lock.h plugin.h pluginmsg.h
image.o: plugindata.h winixbase.h textstream.h misc.h requesttypes.h
image.o: winix_const.h ../../../pikotools/src/convert/convert.h
@ -782,6 +822,7 @@ ipbancontainer.o: ../../../morm/src/postgresqlexpression.h
ipbancontainer.o: ../../../morm/src/jsonconnector.h
ipbancontainer.o: ../../../morm/src/postgresqlconnector.h
ipbancontainer.o: ../../../morm/src/postgresqlqueryresult.h
ipbancontainer.o: ../../../morm/src/transaction.h
ipbancontainer.o: ../../../winix/winixd/core/log.h
ipbancontainer.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
ipbancontainer.o: plugin.h pluginmsg.h plugindata.h winixbase.h
@ -823,8 +864,9 @@ job.o: ../../../morm/src/postgresqlexpression.h
job.o: ../../../morm/src/jsonconnector.h
job.o: ../../../morm/src/postgresqlconnector.h
job.o: ../../../morm/src/postgresqlqueryresult.h
job.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/filelog.h
job.o: lock.h plugin.h pluginmsg.h plugindata.h winixbase.h
job.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
job.o: ../../../winix/winixd/core/filelog.h lock.h plugin.h pluginmsg.h
job.o: plugindata.h winixbase.h
lastcontainer.o: lastcontainer.h ../../../pikotools/src/date/date.h
lastcontainer.o: ../../../pikotools/src/convert/inttostr.h winixbase.h log.h
lastcontainer.o: logmanipulators.h ../../../pikotools/src/log/log.h
@ -862,9 +904,9 @@ lastcontainer.o: ../../../morm/src/jsonexpression.h
lastcontainer.o: ../../../morm/src/postgresqlexpression.h
lastcontainer.o: ../../../morm/src/jsonconnector.h
lastcontainer.o: ../../../morm/src/postgresqlconnector.h
lastcontainer.o: ../../../morm/src/postgresqlqueryresult.h misc.h
lastcontainer.o: requesttypes.h winix_const.h
lastcontainer.o: ../../../pikotools/src/convert/convert.h
lastcontainer.o: ../../../morm/src/postgresqlqueryresult.h
lastcontainer.o: ../../../morm/src/transaction.h misc.h requesttypes.h
lastcontainer.o: winix_const.h ../../../pikotools/src/convert/convert.h
lastcontainer.o: ../../../pikotools/src/convert/inttostr.h
lastcontainer.o: ../../../pikotools/src/convert/patternreplacer.h
lastcontainer.o: ../../../pikotools/src/convert/strtoint.h
@ -919,6 +961,7 @@ loadavg.o: ../../../morm/src/postgresqlexpression.h
loadavg.o: ../../../morm/src/jsonconnector.h
loadavg.o: ../../../morm/src/postgresqlconnector.h
loadavg.o: ../../../morm/src/postgresqlqueryresult.h
loadavg.o: ../../../morm/src/transaction.h
loadavg.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
loadavg.o: ../../../pikotools/src/convert/patternreplacer.h
loadavg.o: ../../../pikotools/src/convert/strtoint.h
@ -968,6 +1011,7 @@ log.o: ../../../morm/src/postgresqlexpression.h
log.o: ../../../morm/src/jsonconnector.h
log.o: ../../../morm/src/postgresqlconnector.h
log.o: ../../../morm/src/postgresqlqueryresult.h
log.o: ../../../morm/src/transaction.h
misc.o: misc.h requesttypes.h ../../../pikotools/src/textstream/textstream.h
misc.o: ../../../pikotools/src/textstream/stream.h
misc.o: ../../../pikotools/src/space/space.h
@ -1019,8 +1063,9 @@ misc.o: ../../../morm/src/postgresqlexpression.h
misc.o: ../../../morm/src/jsonconnector.h
misc.o: ../../../morm/src/postgresqlconnector.h
misc.o: ../../../morm/src/postgresqlqueryresult.h
misc.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/filelog.h
misc.o: lock.h synchro.h ../../../winix/winixd/models/item.h
misc.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
misc.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
misc.o: ../../../winix/winixd/models/item.h
misc.o: ../../../winix/winixd/models/winixmodel.h
misc.o: ../../../winix/winixd/models/winixmodelconnector.h
misc.o: ../../../winix/winixd/models/itemcontent.h
@ -1123,6 +1168,7 @@ mountparser.o: ../../../morm/src/postgresqlexpression.h
mountparser.o: ../../../morm/src/jsonconnector.h
mountparser.o: ../../../morm/src/postgresqlconnector.h
mountparser.o: ../../../morm/src/postgresqlqueryresult.h
mountparser.o: ../../../morm/src/transaction.h
mountparser.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
mountparser.o: ../../../pikotools/src/convert/patternreplacer.h
mountparser.o: ../../../pikotools/src/convert/strtoint.h
@ -1200,6 +1246,7 @@ mounts.o: ../../../morm/src/postgresqlexpression.h
mounts.o: ../../../morm/src/jsonconnector.h
mounts.o: ../../../morm/src/postgresqlconnector.h
mounts.o: ../../../morm/src/postgresqlqueryresult.h
mounts.o: ../../../morm/src/transaction.h
mounts.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
mounts.o: ../../../pikotools/src/convert/patternreplacer.h
mounts.o: ../../../pikotools/src/convert/strtoint.h
@ -1275,7 +1322,7 @@ plugin.o: ../../../morm/src/postgresqlexpression.h
plugin.o: ../../../morm/src/jsonconnector.h
plugin.o: ../../../morm/src/postgresqlconnector.h
plugin.o: ../../../morm/src/postgresqlqueryresult.h
plugin.o: ../../../winix/winixd/core/log.h
plugin.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
plugin.o: ../../../winix/winixd/core/filelog.h lock.h dirs.h dircontainer.h
plugin.o: ../../../winix/winixd/models/item.h
plugin.o: ../../../winix/winixd/models/winixmodel.h
@ -1414,7 +1461,8 @@ plugindata.o: ../../../morm/src/postgresqlexpression.h
plugindata.o: ../../../morm/src/jsonconnector.h
plugindata.o: ../../../morm/src/postgresqlconnector.h
plugindata.o: ../../../morm/src/postgresqlqueryresult.h
postmultiparser.o: postmultiparser.h error.h requesttypes.h
plugindata.o: ../../../morm/src/transaction.h
postmultiparser.o: postmultiparser.h error.h request.h requesttypes.h
postmultiparser.o: ../../../pikotools/src/textstream/textstream.h
postmultiparser.o: ../../../pikotools/src/textstream/stream.h
postmultiparser.o: ../../../pikotools/src/space/space.h
@ -1427,24 +1475,20 @@ postmultiparser.o: ../../../pikotools/src/utf8/utf8_private.h
postmultiparser.o: ../../../pikotools/src/date/date.h
postmultiparser.o: ../../../pikotools/src/membuffer/membuffer.h
postmultiparser.o: ../../../pikotools/src/textstream/types.h
postmultiparser.o: ../../../pikotools/src/utf8/utf8_stream.h config.h misc.h
postmultiparser.o: winix_const.h ../../../pikotools/src/convert/convert.h
postmultiparser.o: ../../../pikotools/src/convert/inttostr.h
postmultiparser.o: ../../../pikotools/src/convert/patternreplacer.h
postmultiparser.o: ../../../pikotools/src/convert/strtoint.h
postmultiparser.o: ../../../pikotools/src/convert/text.h
postmultiparser.o: ../../../pikotools/src/convert/double.h winixbase.h log.h
postmultiparser.o: logmanipulators.h ../../../pikotools/src/log/log.h
postmultiparser.o: filelog.h ../../../winix/winixd/core/synchro.h
postmultiparser.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
postmultiparser.o: ../../../pikotools/src/utf8/utf8_stream.h
postmultiparser.o: ../../../winix/winixd/models/item.h
postmultiparser.o: ../../../winix/winixd/models/winixmodel.h
postmultiparser.o: ../../../morm/src/model.h
postmultiparser.o: ../../../morm/src/modelconnector.h
postmultiparser.o: ../../../morm/src/clearer.h ../../../morm/src/ft.h
postmultiparser.o: ../../../morm/src/dbconnector.h
postmultiparser.o: ../../../pikotools/src/log/log.h filelog.h
postmultiparser.o: ../../../winix/winixd/core/synchro.h
postmultiparser.o: ../../../morm/src/queryresult.h
postmultiparser.o: ../../../morm/src/flatconnector.h
postmultiparser.o: ../../../morm/src/dbexpression.h
postmultiparser.o: ../../../morm/src/baseexpression.h
postmultiparser.o: ../../../morm/src/morm_types.h
postmultiparser.o: ../../../morm/src/modelenv.h ../../../morm/src/modeldata.h
postmultiparser.o: ../../../morm/src/cursorhelper.h
postmultiparser.o: ../../../morm/src/finderhelper.h
@ -1455,12 +1499,44 @@ postmultiparser.o: ../../../morm/src/baseobjectwrapper.h
postmultiparser.o: ../../../morm/src/modelcontainerwrapper.h
postmultiparser.o: ../../../pikotools/src/convert/text.h
postmultiparser.o: ../../../morm/src/flatexpression.h
postmultiparser.o: ../../../winix/winixd/core/log.h
postmultiparser.o: ../../../winix/winixd/models/winixmodelconnector.h
postmultiparser.o: ../../../winix/winixd/models/itemcontent.h
postmultiparser.o: ../../../winix/winixd/templates/htmltextstream.h
postmultiparser.o: ../../../winix/winixd/templates/misc.h
postmultiparser.o: ../../../winix/winixd/templates/localefilter.h
postmultiparser.o: ../../../winix/winixd/templates/locale.h
postmultiparser.o: ../../../pikotools/src/space/spaceparser.h
postmultiparser.o: ../../../pikotools/src/space/space.h
postmultiparser.o: ../../../pikotools/src/convert/baseparser.h
postmultiparser.o: ../../../winix/winixd/core/winixbase.h
postmultiparser.o: ../../../winix/winixd/core/config.h log.h
postmultiparser.o: logmanipulators.h ../../../morm/src/morm.h
postmultiparser.o: ../../../morm/src/finder.h ../../../morm/src/cursor.h
postmultiparser.o: ../../../morm/src/jsonexpression.h
postmultiparser.o: ../../../morm/src/postgresqlexpression.h
postmultiparser.o: ../../../morm/src/jsonconnector.h
postmultiparser.o: ../../../morm/src/postgresqlconnector.h
postmultiparser.o: ../../../morm/src/postgresqlqueryresult.h
postmultiparser.o: ../../../morm/src/transaction.h
postmultiparser.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
postmultiparser.o: ../../../pikotools/src/convert/patternreplacer.h
postmultiparser.o: ../../../pikotools/src/convert/strtoint.h
postmultiparser.o: ../../../pikotools/src/convert/text.h misc.h winix_const.h
postmultiparser.o: ../../../pikotools/src/convert/convert.h
postmultiparser.o: ../../../pikotools/src/convert/inttostr.h
postmultiparser.o: ../../../pikotools/src/convert/patternreplacer.h
postmultiparser.o: ../../../pikotools/src/convert/double.h
postmultiparser.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
postmultiparser.o: ../../../ezc/src/blocks.h ../../../ezc/src/item.h
postmultiparser.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
postmultiparser.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
postmultiparser.o: ../../../ezc/src/pattern.h ../../../ezc/src/outstreams.h
postmultiparser.o: ../../../ezc/src/expressionparser.h
postmultiparser.o: ../../../ezc/src/models.h ../../../ezc/src/patternparser.h
postmultiparser.o: ../../../winix/winixd/templates/htmltextstream.h config.h
postmultiparser.o: textstream.h ../../../winix/winixd/models/winixmodel.h
postmultiparser.o: header.h winixbase.h
rebus.o: log.h logmanipulators.h ../../../pikotools/src/log/log.h
rebus.o: ../../../pikotools/src/textstream/textstream.h
rebus.o: ../../../pikotools/src/textstream/stream.h
@ -1493,7 +1569,8 @@ rebus.o: ../../../morm/src/cursor.h ../../../morm/src/jsonexpression.h
rebus.o: ../../../morm/src/postgresqlexpression.h
rebus.o: ../../../morm/src/jsonconnector.h
rebus.o: ../../../morm/src/postgresqlconnector.h
rebus.o: ../../../morm/src/postgresqlqueryresult.h rebus.h winixbase.h misc.h
rebus.o: ../../../morm/src/postgresqlqueryresult.h
rebus.o: ../../../morm/src/transaction.h rebus.h winixbase.h misc.h
rebus.o: requesttypes.h winix_const.h
rebus.o: ../../../pikotools/src/convert/convert.h
rebus.o: ../../../pikotools/src/convert/inttostr.h
@ -1577,6 +1654,7 @@ request.o: ../../../morm/src/postgresqlexpression.h
request.o: ../../../morm/src/jsonconnector.h
request.o: ../../../morm/src/postgresqlconnector.h
request.o: ../../../morm/src/postgresqlqueryresult.h
request.o: ../../../morm/src/transaction.h
request.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
request.o: ../../../pikotools/src/convert/patternreplacer.h
request.o: ../../../pikotools/src/convert/strtoint.h
@ -1620,7 +1698,12 @@ request.o: ../../../winix/winixd/core/winixsystem.h winixmodeldeprecated.h
request.o: ../../../winix/winixd/core/cur.h
request.o: ../../../winix/winixd/core/sessionmanager.h
request.o: ../../../winix/winixd/core/slog.h cur.h session.h rebus.h ipban.h
request.o: mount.h
request.o: mount.h ../../../winix/winixd/templates/templates.h
request.o: ../../../winix/winixd/templates/patterncacher.h
request.o: ../../../winix/winixd/templates/indexpatterns.h
request.o: ../../../winix/winixd/templates/patterns.h
request.o: ../../../winix/winixd/templates/changepatterns.h
request.o: ../../../pikotools/src/html/htmlparser.h
run.o: run.h winixbase.h
session.o: session.h error.h ../../../winix/winixd/models/user.h
session.o: ../../../morm/src/model.h
@ -1666,7 +1749,7 @@ session.o: ../../../morm/src/postgresqlexpression.h
session.o: ../../../morm/src/jsonconnector.h
session.o: ../../../morm/src/postgresqlconnector.h
session.o: ../../../morm/src/postgresqlqueryresult.h
session.o: ../../../winix/winixd/core/log.h
session.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
session.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
session.o: ../../../pikotools/src/convert/patternreplacer.h
session.o: ../../../pikotools/src/convert/strtoint.h
@ -1737,6 +1820,7 @@ sessioncontainer.o: ../../../morm/src/postgresqlexpression.h
sessioncontainer.o: ../../../morm/src/jsonconnector.h
sessioncontainer.o: ../../../morm/src/postgresqlconnector.h
sessioncontainer.o: ../../../morm/src/postgresqlqueryresult.h
sessioncontainer.o: ../../../morm/src/transaction.h
sessioncontainer.o: ../../../winix/winixd/core/log.h
sessioncontainer.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
sessioncontainer.o: ../../../pikotools/src/convert/patternreplacer.h
@ -1840,6 +1924,7 @@ sessionmanager.o: ../../../morm/src/postgresqlexpression.h
sessionmanager.o: ../../../morm/src/jsonconnector.h
sessionmanager.o: ../../../morm/src/postgresqlconnector.h
sessionmanager.o: ../../../morm/src/postgresqlqueryresult.h
sessionmanager.o: ../../../morm/src/transaction.h
sessionmanager.o: ../../../winix/winixd/core/log.h
sessionmanager.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
sessionmanager.o: ../../../pikotools/src/convert/patternreplacer.h
@ -1948,6 +2033,7 @@ sessionparser.o: ../../../morm/src/postgresqlexpression.h
sessionparser.o: ../../../morm/src/jsonconnector.h
sessionparser.o: ../../../morm/src/postgresqlconnector.h
sessionparser.o: ../../../morm/src/postgresqlqueryresult.h
sessionparser.o: ../../../morm/src/transaction.h
sessionparser.o: ../../../winix/winixd/core/log.h
sessionparser.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
sessionparser.o: ../../../pikotools/src/convert/patternreplacer.h
@ -2030,8 +2116,8 @@ slog.o: ../../../morm/src/postgresqlexpression.h
slog.o: ../../../morm/src/jsonconnector.h
slog.o: ../../../morm/src/postgresqlconnector.h
slog.o: ../../../morm/src/postgresqlqueryresult.h
slog.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
slog.o: ../../../pikotools/src/convert/patternreplacer.h
slog.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/filelog.h
slog.o: lock.h synchro.h ../../../pikotools/src/convert/patternreplacer.h
slog.o: ../../../pikotools/src/convert/strtoint.h
slog.o: ../../../pikotools/src/convert/text.h misc.h winix_const.h
slog.o: ../../../pikotools/src/convert/convert.h
@ -2088,7 +2174,7 @@ system.o: ../../../morm/src/postgresqlexpression.h
system.o: ../../../morm/src/jsonconnector.h
system.o: ../../../morm/src/postgresqlconnector.h
system.o: ../../../morm/src/postgresqlqueryresult.h
system.o: ../../../winix/winixd/core/log.h
system.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
system.o: ../../../winix/winixd/core/filelog.h lock.h plugin.h pluginmsg.h
system.o: plugindata.h winixbase.h dirs.h dircontainer.h
system.o: ../../../winix/winixd/models/item.h
@ -2240,6 +2326,7 @@ threadmanager.o: ../../../morm/src/postgresqlexpression.h
threadmanager.o: ../../../morm/src/jsonconnector.h
threadmanager.o: ../../../morm/src/postgresqlconnector.h
threadmanager.o: ../../../morm/src/postgresqlqueryresult.h
threadmanager.o: ../../../morm/src/transaction.h
threadmanager.o: ../../../winix/winixd/core/log.h
threadmanager.o: ../../../winix/winixd/core/filelog.h lock.h plugin.h
threadmanager.o: pluginmsg.h plugindata.h winixbase.h
@ -2308,6 +2395,7 @@ timezones.o: ../../../morm/src/postgresqlexpression.h
timezones.o: ../../../morm/src/jsonconnector.h
timezones.o: ../../../morm/src/postgresqlconnector.h
timezones.o: ../../../morm/src/postgresqlqueryresult.h
timezones.o: ../../../morm/src/transaction.h
users.o: users.h ../../../winix/winixd/models/user.h
users.o: ../../../morm/src/model.h
users.o: ../../../pikotools/src/textstream/textstream.h
@ -2351,7 +2439,7 @@ users.o: ../../../morm/src/postgresqlexpression.h
users.o: ../../../morm/src/jsonconnector.h
users.o: ../../../morm/src/postgresqlconnector.h
users.o: ../../../morm/src/postgresqlqueryresult.h
users.o: ../../../winix/winixd/core/log.h
users.o: ../../../morm/src/transaction.h ../../../winix/winixd/core/log.h
users.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
users.o: ../../../pikotools/src/convert/patternreplacer.h
users.o: ../../../pikotools/src/convert/strtoint.h
@ -2447,6 +2535,7 @@ winixmodeldeprecated.o: ../../../morm/src/postgresqlexpression.h
winixmodeldeprecated.o: ../../../morm/src/jsonconnector.h
winixmodeldeprecated.o: ../../../morm/src/postgresqlconnector.h
winixmodeldeprecated.o: ../../../morm/src/postgresqlqueryresult.h
winixmodeldeprecated.o: ../../../morm/src/transaction.h
winixmodeldeprecated.o: ../../../winix/winixd/core/log.h
winixmodeldeprecated.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h
winixmodeldeprecated.o: plugin.h pluginmsg.h plugindata.h winixbase.h
@ -2493,6 +2582,7 @@ winixsystem.o: ../../../morm/src/postgresqlexpression.h
winixsystem.o: ../../../morm/src/jsonconnector.h
winixsystem.o: ../../../morm/src/postgresqlconnector.h
winixsystem.o: ../../../morm/src/postgresqlqueryresult.h
winixsystem.o: ../../../morm/src/transaction.h
winixsystem.o: ../../../winix/winixd/core/log.h
winixsystem.o: ../../../winix/winixd/core/filelog.h lock.h synchro.h plugin.h
winixsystem.o: pluginmsg.h plugindata.h winixbase.h

2
winixd/core/Makefile.o.dep

@ -1 +1 @@
o = app.o basethread.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o httpsimpleparser.o image.o ipbancontainer.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o users.o winixbase.o winixmodeldeprecated.o winixrequest.o winixsystem.o
o = app.o basethread.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o header.o httpsimpleparser.o image.o ipbancontainer.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o users.o winixbase.o winixmodeldeprecated.o winixrequest.o winixsystem.o

538
winixd/core/app.cpp

@ -612,6 +612,7 @@ bool App::CheckAccessFromPlugins()
if( res.res_false > 0 )
{
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
cur.request->http_status = Header::status_403_forbidden;
log << log2 << "App: access prevented by a plugin" << logend;
return false;
}
@ -621,102 +622,155 @@ return true;
void App::ProcessRequestThrow()
/*
* REFACTOR ME
*/
void App::MakeRenameMeToABetterName()
{
ReadRequest();
if( cur.request->function )
{
cur.request->function->fun.set_connector(model_connector); // IMPROVEME may would be better to add set_connector() method to functions?
cur.request->function->fun.propagate_connector();
}
// when BaseUrlRedirect() return true we didn't have to set everything in cur.request->Read()
// in the future cur.request->Read() can be split and at the beginning only environment variables will be read
// and then BaseUrlRedirect() will be called (for performance)
if( !BaseUrlRedirect() )
/*
* set global connector for now
* in the future each thread will have its own model_connector
*
* don't set connector for item_tab - it will be moved out from request
*/
cur.request->item.set_connector(model_connector);
cur.mount = system.mounts.CalcCurMount();
cur.session = session_manager.PrepareSession();
model_connector.set_winix_session(cur.session);
functions.CheckFunctionAndSymlink(); // here a function can be changed
if( cur.request->function )
{
if( cur.request->env_request_uri.size() <= WINIX_URL_MAX_SIZE )
{
functions.Parse(); // parsing directories, files, functions and parameters
cur.request->function->fun.set_connector(model_connector);
cur.request->function->fun.propagate_connector();
}
if( cur.request->function )
{
cur.request->function->fun.set_connector(model_connector); // IMPROVEME may would be better to add set_connector() method to functions?
cur.request->function->fun.propagate_connector();
}
cur.session = session_manager.CheckIfFunctionRequireSession();
model_connector.set_winix_session(cur.session);
/*
* set global connector for now
* in the future each thread will have its own model_connector
*
* don't set connector for item_tab - it will be moved out from request
*/
cur.request->item.set_connector(model_connector);
SetLocale();
if( !cur.request->dir_tab.empty() )
{
cur.mount = system.mounts.CalcCurMount();
if( cur.session->new_session )
{
cur.session->plugin_data.Resize(plugin.Size());
plugin.Call(WINIX_SESSION_CREATED);
}
cur.session = session_manager.PrepareSession();
model_connector.set_winix_session(cur.session);
plugin.Call(WINIX_SESSION_CHANGED);
functions.CheckFunctionAndSymlink(); // here a function can be changed
if( cur.request->function )
{
cur.request->function->fun.set_connector(model_connector);
cur.request->function->fun.propagate_connector();
}
////////////////////////
cur.session = session_manager.CheckIfFunctionRequireSession();
model_connector.set_winix_session(cur.session);
SetLocale();
cur.request->PrepareAnswerType();
if( cur.session->new_session )
{
cur.session->plugin_data.Resize(plugin.Size());
plugin.Call(WINIX_SESSION_CREATED);
}
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{
pt::Date date(cur.session->ip_ban->expires);
plugin.Call(WINIX_SESSION_CHANGED);
}
}
else
{
/*
* IMPROVE ME
* it will not have the root directory set
* so as a response only a blank page is shown
* (root directory is set in funcions.Parse())
*
* IMPROVE ME
* we can add a better return code (http status):
* http://www.ietf.org/rfc/rfc2616.txt
* "A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle"
*
*/
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
log << log1 << "App: the URL is too long: " << cur.request->env_request_uri.size() << logend;
}
// IMPROVE ME there is no slog now
//slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty), adding a root dir" << logend;
Item * root_dir = system.dirs.GetRootDir();
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
cur.request->http_status = Header::status_403_forbidden;
}
// cur.request->status can be changed by function_parser
if( cur.request->status == WINIX_ERR_OK && cur.request->http_status == Header::status_200_ok )
plugin.Call(WINIX_PREPARE_REQUEST);
// if( cur.request->status == WINIX_ERR_OK )
// functions.CheckFunctionAndSymlink();
CheckAccessFromPlugins();
// !! CHECK ME CheckFunctionAndSymlink can set redirect_to
// may it should be tested before calling CheckIfNeedSSLredirect?
CheckIfNeedSSLredirect();
if( !cur.request->redirect_to.empty() )
return;
AddDefaultModels();
if( root_dir )
if( cur.request->status == WINIX_ERR_OK && cur.request->http_status == Header::status_200_ok )
functions.MakeFunction();
if( cur.session->spam_score > 0 )
log << log1 << "App: spam score: " << cur.session->spam_score << logend;
if( cur.request->IsParam(L"noredirect") )
cur.request->redirect_to.clear();
if( cur.request->status == WINIX_ERR_OK && cur.request->http_status == Header::status_200_ok )
plugin.Call(WINIX_PROCESS_REQUEST);
CheckPostRedirect();
if( !cur.request->redirect_to.empty() )
return;
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty -- after calling a function)" << logend;
return;
}
}
bool App::AddRootDir()
{
Item * root_dir = system.dirs.GetRootDir();
if( root_dir )
{
cur.request->dir_tab.push_back(root_dir);
cur.request->last_item = cur.request->dir_tab.back();
}
else
{
log << log3 << "App: there is no a root directory" << logend;
cur.request->http_status = Header::status_404_not_found;
}
return root_dir != nullptr;
}
void App::ProcessRequestThrow()
{
if( AddRootDir() )
{
ReadRequest();
if( !BaseUrlRedirect() )
{
if( functions.Parse() )
{
cur.request->dir_tab.push_back(root_dir);
cur.request->last_item = cur.request->dir_tab.back();
cur.mount = system.mounts.CalcCurMount();
ReadPostVars();
}
else
if( cur.mount->type != system.mounts.MountTypeStatic() )
{
log << log1 << "App: oops, we do not have a root dir" << logend;
MakeRenameMeToABetterName();
}
}
if( cur.mount->type != system.mounts.MountTypeStatic() )
Make();
}
SendAnswer();
}
@ -732,6 +786,8 @@ void App::ProcessRequest()
log << log2 << config.log_delimiter << logend;
ProcessRequestThrow();
ModifyStatusCodeIfNeeded();
SendAnswer();
SaveSessionsIfNeeded();
cur.request->RequestEnds();
@ -784,6 +840,7 @@ void App::ClearAfterRequest()
aheader_value.clear();
cur.mount = system.mounts.GetEmptyMount();
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
post_log_tmp_buffer.clear();
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
model_connector.set_winix_request(nullptr);
@ -908,70 +965,6 @@ void App::AddDefaultModels()
// !! IMPROVE ME change to a better name
// may ProcessRequest()? but probably it is already defined...
// this method needs some refactoring
void App::Make()
{
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty)" << logend;
return;
}
cur.request->PrepareAnswerType();
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
{
pt::Date date(cur.session->ip_ban->expires);
// IMPROVE ME there is no slog now
//slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
}
// cur.request->status can be changed by function_parser
if( cur.request->status == WINIX_ERR_OK )
plugin.Call(WINIX_PREPARE_REQUEST);
// if( cur.request->status == WINIX_ERR_OK )
// functions.CheckFunctionAndSymlink();
CheckAccessFromPlugins();
// !! CHECK ME CheckFunctionAndSymlink can set redirect_to
// may it should be tested before calling CheckIfNeedSSLredirect?
CheckIfNeedSSLredirect();
if( !cur.request->redirect_to.empty() )
return;
AddDefaultModels();
if( cur.request->status == WINIX_ERR_OK )
functions.MakeFunction();
if( cur.session->spam_score > 0 )
log << log1 << "App: spam score: " << cur.session->spam_score << logend;
if( cur.request->IsParam(L"noredirect") )
cur.request->redirect_to.clear();
if( cur.request->status == WINIX_ERR_OK )
plugin.Call(WINIX_PROCESS_REQUEST);
CheckPostRedirect();
if( !cur.request->redirect_to.empty() )
return;
if( cur.request->dir_tab.empty() )
{
log << log1 << "App: there is no a root dir (dir_tab is empty -- after calling a function)" << logend;
return;
}
}
void App::LogEnvironmentVariables()
@ -1052,7 +1045,7 @@ void App::ReadRequest()
LogAccess();
ReadEnvHTTPVariables();
ReadPostVars();
//ReadPostVars();
if( config.log_env_variables )
LogEnvironmentVariables();
@ -1071,6 +1064,7 @@ void App::ReadRequest()
if( cur.request->using_ssl )
log << log3 << "App: connection secure through SSL" << logend;
}
@ -1293,8 +1287,7 @@ void App::LogAccess()
}
void App::ReadPostJson()
void App::ReadInputPostToBuffer()
{
char buffer[1024];
const int buffer_len = sizeof(buffer) / sizeof(char) - 1;
@ -1303,34 +1296,89 @@ void App::ReadPostJson()
post_buffer.clear();
post_buffer.reserve(1024 * 1024 * 5); // IMPROVEME add to config?
cur.request->is_postin_used = true;
do
{
// IMPROVE ME
// we can read to pt::TextBuffer and make a pt::JSONToSpaceParser::Parse(pt::TextBuffer &) method
read_len = FCGX_GetStr(buffer, buffer_len, fcgi_request.in);
if( read_len > 0 )
post_buffer.append(buffer, read_len);
post_buffer.write(buffer, read_len);
}
while( read_len == buffer_len );
if( !post_buffer.empty() )
}
void App::ParsePostJson()
{
FunctionBase * fun = cur.request->function;
space_parser.set_object_items_limit( (fun && fun->post_max_object_items != 0) ? fun->post_max_object_items : config.post_max_object_items);
space_parser.set_table_items_limit( (fun && fun->post_max_table_items != 0) ? fun->post_max_table_items : config.post_max_table_items);
space_parser.set_all_items_limit( (fun && fun->post_max_all_items != 0) ? fun->post_max_all_items : config.post_max_all_items);
space_parser.set_nested_level_limit( (fun && fun->post_max_nested_objects != 0) ? fun->post_max_nested_objects : config.post_max_nested_objects);
pt::SpaceParser::Status parse_status = space_parser.parse_json(post_buffer, cur.request->post_in);
if( parse_status == pt::SpaceParser::ok )
{
pt::SpaceParser::Status status = space_parser.parse_json(post_buffer.c_str(), cur.request->post_in);
post_buffer.clear();
}
else
if( parse_status == pt::SpaceParser::syntax_error )
{
log << log1 << "App: cannot parse the input stream as an JSON object"
<< ", syntax error in line: " << space_parser.get_last_parsed_line() << ":" << space_parser.get_last_parsed_column() << logend;
if( status != pt::SpaceParser::ok )
{
log << log1 << "App: cannot parse the input stream as an JSON object";
cur.request->post_in.clear();
cur.request->http_status = Header::status_400_bad_request;
}
else
if( parse_status == pt::SpaceParser::limit_object_items_exceeded )
{
log << log1 << "App: object items limit exceeded when parsing input JSON object" << logend;
cur.request->post_in.clear();
cur.request->http_status = Header::status_400_bad_request;
}
else
if( parse_status == pt::SpaceParser::limit_table_items_exceeded )
{
log << log1 << "App: table items limit exceeded when parsing input JSON object" << logend;
cur.request->post_in.clear();
cur.request->http_status = Header::status_400_bad_request;
}
else
if( parse_status == pt::SpaceParser::limit_all_items_exceeded )
{
log << log1 << "App: all items limit exceeded when parsing input JSON object" << logend;
cur.request->post_in.clear();
cur.request->http_status = Header::status_400_bad_request;
}
else
if( parse_status == pt::SpaceParser::limit_nested_level_exceeded )
{
log << log1 << "App: nested objects/tables limit exceeded when parsing input JSON object" << logend;
cur.request->post_in.clear();
cur.request->http_status = Header::status_400_bad_request;
}
}
if( status == pt::SpaceParser::syntax_error )
log << ", syntax error in line: " << space_parser.get_last_parsed_line() << logend;
cur.request->post_in.clear();
// return an error (http error of some kind?)
void App::ReadPostJson()
{
ReadInputPostToBuffer();
if( !post_buffer.empty() )
{
if( config.post_json_max == 0 || post_buffer.size() <= config.post_json_max )
{
ParsePostJson();
}
else
{
log << log1 << "App: the input stream exceeded the limit of " << config.post_json_max << " bytes (skipping parsing)" << logend;
cur.request->http_status = Header::status_400_bad_request;
}
post_buffer.clear();
}
else
{
@ -1342,26 +1390,29 @@ void App::ReadPostJson()
void App::ReadPostVars()
{
// CHECKME
// what about errors during parsing input?
if( cur.request->method == Request::post || cur.request->method == Request::delete_ )
{
if( pt::is_substr_nc(L"multipart/form-data", cur.request->env_content_type.c_str()) )
{
log << log3 << "App: post content type: multipart/form-data" << logend;
post_multi_parser.Parse(fcgi_request.in, cur.request->post_tab, cur.request->post_file_tab);
post_multi_parser.Parse(fcgi_request.in, *cur.request); // IMPROVEME add checking for return status
}
else
if( pt::is_substr_nc(Winix::Header::application_json, cur.request->env_content_type.c_str()) )
{
log << log3 << "App: post content type: " << Winix::Header::application_json << logend;
log << log3 << "App: post content type: " << Winix::Header::application_json << ", using json parser" << logend;
ReadPostJson();
}
else
{
// IMPROVE ME may to check a correct content-type header?
post_parser.Parse(fcgi_request.in, cur.request->post_tab);
post_parser.Parse(fcgi_request.in, *cur.request); // IMPROVEME add checking for return status
}
if( config.log_whole_http_post )
{
cur.request->post_in.serialize_to_json_stream(post_log_tmp_buffer, true);
log << log3 << "App: the whole http post after parsing:" << logend << post_log_tmp_buffer << logend;
}
}
}
@ -1464,7 +1515,7 @@ return false;
}
bool App::PrepareHeadersStaticCreateResource(pt::WTextStream & out_path)
bool App::CreateStaticResourcePath(pt::WTextStream & out_path)
{
size_t i = 0;
Item * dir = system.dirs.GetDir(system.mounts.pmount->dir_id);
@ -1476,7 +1527,7 @@ bool App::PrepareHeadersStaticCreateResource(pt::WTextStream & out_path)
}
size_t how_many_dirs = system.dirs.DirLevel(dir->id);
const wchar_t * path = SkipDirs(cur.request->env_request_uri.c_str(), how_many_dirs);
const wchar_t * path = SkipDirs(cur.request->env_request_uri.c_str(), how_many_dirs);
// the path begins with a slash only if how_many_dirs is zero
while( *path == '/' )
@ -1492,12 +1543,12 @@ return true;
}
void App::PrepareHeadersStatic()
void App::PrepareSendFileHeaderForStaticMountpoint()
{
if( PathHasUpDir(cur.request->env_request_uri) )
{
log << log1 << "App: incorrect path for a static file" << logend;
PrepareHeadersForbidden();
cur.request->http_status = Header::status_403_forbidden;
return;
}
@ -1507,27 +1558,27 @@ void App::PrepareHeadersStatic()
if( index >= config.static_dirs.size() )
{
log << log1 << "App: static dir with index " << index << " is not defined in the config" << logend;
PrepareHeadersForbidden();
cur.request->http_status = Header::status_403_forbidden;
return;
}
pt::WTextStream path;
path << config.static_dirs[index] << L"/";
if( !PrepareHeadersStaticCreateResource(path) )
if( !CreateStaticResourcePath(path) )
{
PrepareHeadersForbidden();
cur.request->http_status = Header::status_403_forbidden;
return;
}
AddHeader(L"Status", L"200 OK");
/*
* FIX ME now we can send full path (apache, lighttpd) and relative path (nginx)
* but this feature for mounting static content probably will be removed
* FIX ME now we can send full path (apache, lighttpd) and relative path (nginx)
* but this feature for mounting static content probably will be removed
*/
if( AddHeader(config.send_file_header, path) )
{
log << log2 << "App: sending a file from a static mountpoint: " << path << logend;
}
}
@ -1579,80 +1630,58 @@ void App::PrepareHeaderContentType()
void App::PrepareHeadersForbidden()
{
AddHeader(L"Status", L"403 Forbidden");
PrepareHeaderContentType();
}
void App::PrepareHeadersRedirect()
void App::ModifyStatusForRedirect()
{
switch(cur.request->redirect_type)
{
case 300:
AddHeader(L"Status", L"300 Multiple Choices");
cur.request->http_status = Header::status_300_multiple_choices;
break;
case 301:
AddHeader(L"Status", L"301 Moved Permanently");
cur.request->http_status = Header::status_301_moved_permanently;
break;
case 302:
AddHeader(L"Status", L"302 Found");
cur.request->http_status = Header::status_302_found;
break;
case 307:
AddHeader(L"Status", L"307 Temporary Redirect");
cur.request->http_status = Header::status_307_temporary_redirect;
break;
case 303:
default:
AddHeader(L"Status", L"303 See Other");
cur.request->http_status = Header::status_303_see_other;
break;
}
AddHeader(L"Location", cur.request->redirect_to);
log << log2 << "App: redirect to: " << cur.request->redirect_to << logend;
}
void App::PrepareHeadersSendFile()
void App::PrepareSendFileHeader()
{
AddHeader(L"Status", L"200 OK");
if( AddHeader(config.send_file_header, cur.request->x_sendfile) )
{
log << log2 << "App: sending file: " << cur.request->x_sendfile << logend;
}
}
void App::PrepareHeadersCompression(int compress_encoding)
void App::PrepareContentEncodingHeader(int compress_encoding)
{
if( compress_encoding == 0 || compress_encoding == 1 )
{
AddHeader(L"Content-Encoding", L"deflate");
}
else
{
AddHeader(L"Content-Encoding", L"gzip");
}
}
void App::PrepareHeadersNormal(Header header, size_t output_size)
void App::PrepareContentLengthHeader(size_t output_size)
{
switch( header )
{
case h_404:
AddHeader(L"Status", L"404 Not Found");
PrepareHeaderContentType();
break;
case h_403:
PrepareHeadersForbidden();
break;
default:
AddHeader(L"Status", L"200 OK");
PrepareHeaderContentType();
}
if( output_size != static_cast<size_t>(-1) )
{
pt::WTextStream buf;
@ -1734,35 +1763,53 @@ void App::SendCookies()
}
void App::PrepareHeaders(bool compressing, int compress_encoding, Header header, size_t output_size)
void App::PrepareHeaderStatus(int http_status)
{
pt::WTextStream value;
Header::prepare_status_value(http_status, value, false);
AddHeader(L"Status", value);
log << log2 << "App: http status: " << value << logend;
}
void App::PrepareHeaders(bool compressing, int compress_encoding, size_t output_size)
{
PrepareSessionCookie();
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() )
{
PrepareHeadersRedirect();
ModifyStatusForRedirect();
AddHeader(L"Location", cur.request->redirect_to);
log << log2 << "App: redirect to: " << cur.request->redirect_to << logend;
}
else
if( system.mounts.pmount->type == system.mounts.MountTypeStatic() )
{
PrepareHeadersStatic();
PrepareSendFileHeaderForStaticMountpoint();
}
else
if( !cur.request->x_sendfile.empty() )
{
PrepareHeadersSendFile();
PrepareSendFileHeader();
}
else
{
PrepareHeadersNormal(header, output_size);
PrepareContentLengthHeader(output_size);
}
if( compressing )
PrepareHeadersCompression(compress_encoding);
{
PrepareContentEncodingHeader(compress_encoding);
}
PrepareHeaderStatus(cur.request->http_status);
PrepareHeaderContentType();
}
@ -1804,7 +1851,6 @@ void App::SelectCompression(size_t source_len, bool & compression_allowed, int &
}
}
if( config.compression_encoding == 2 || config.compression_encoding == 20 )
{
if( accept_encoding_parser.AcceptGzip() )
@ -1833,54 +1879,53 @@ 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->redirect_to.empty() )
{
// if there is a redirect and no json is requred then we do not send the content
return false;
}
/*
we don't have to check the HEAD method
the server (lighttpd) doesn't send the body of its own
*/
if( cur.request->method == Request::head )
{
return false;
}
return true;
return true;
}