2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2022-02-02 18:34:22 +01:00
|
|
|
* Copyright (c) 2008-2022, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-10 05:42:49 +01:00
|
|
|
*/
|
2009-11-21 00:09:52 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
#include "request.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "log.h"
|
2009-11-13 21:40:11 +01:00
|
|
|
#include "plugin.h"
|
2009-11-21 00:09:52 +01:00
|
|
|
#include "misc.h"
|
2021-06-20 20:47:59 +02:00
|
|
|
#include "functions/functionbase.h"
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
#include "templates/templates.h"
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
2009-11-13 21:40:11 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2014-10-09 22:44:56 +02:00
|
|
|
Request::Request()
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
id = 0;
|
2013-12-23 04:29:33 +01:00
|
|
|
config = 0;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2021-06-17 21:44:29 +02:00
|
|
|
void Request::fields()
|
|
|
|
{
|
2021-07-03 01:14:53 +02:00
|
|
|
field(L"", L"dirs", dir_tab);
|
|
|
|
field(L"", L"is_item", is_item);
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
field(L"", L"http_status", http_status);
|
|
|
|
|
2021-07-03 01:14:53 +02:00
|
|
|
field(L"", L"current_dir", &Request::current_dir);
|
|
|
|
field(L"", L"last_item", &Request::last_item_wrapper);
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
field(L"", L"http_status_error_title", &Request::http_status_error_title);
|
|
|
|
field(L"", L"http_status_error_description", &Request::http_status_error_description);
|
2021-06-17 21:44:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void Request::SetConfig(Config * pconfig)
|
|
|
|
{
|
|
|
|
config = pconfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-14 21:59:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
void Request::ClearOutputStreams()
|
2012-08-08 18:04:48 +02:00
|
|
|
{
|
2015-11-15 23:23:36 +01:00
|
|
|
size_t len = 0;
|
|
|
|
|
2021-07-16 18:17:57 +02:00
|
|
|
out_main_stream.clear();
|
2013-12-23 04:29:33 +01:00
|
|
|
|
|
|
|
if( config )
|
|
|
|
len = config->ezc_out_streams_size;
|
2013-11-29 22:39:23 +01:00
|
|
|
|
2015-11-15 23:23:36 +01:00
|
|
|
/*
|
|
|
|
* clearing buffers and setting 'escape' flag to true
|
|
|
|
* for all streams which were used in the map
|
|
|
|
*/
|
|
|
|
out_streams.ClearMap();
|
|
|
|
out_streams.ResizeTab(len);
|
2013-11-14 21:59:23 +01:00
|
|
|
}
|
2009-09-22 01:05:05 +02:00
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
void Request::Clear()
|
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
// id is never 0
|
|
|
|
if( ++id == 0 )
|
|
|
|
++id;
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
RemovePostFileTmp(post_file_tab);
|
2013-11-14 21:59:23 +01:00
|
|
|
ClearOutputStreams();
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2021-06-20 20:47:59 +02:00
|
|
|
if( function )
|
|
|
|
function->Clear();
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
post_file_tab.clear();
|
|
|
|
cookie_tab.clear();
|
2021-04-09 17:50:58 +02:00
|
|
|
post_in.clear();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2013-11-29 22:39:23 +01:00
|
|
|
method = unknown_method;
|
2013-11-14 21:59:23 +01:00
|
|
|
|
2021-04-09 17:50:58 +02:00
|
|
|
headers_in.clear();
|
2018-04-25 21:48:47 +02:00
|
|
|
|
2021-04-09 17:50:58 +02:00
|
|
|
out_headers.clear();
|
|
|
|
out_cookies.clear();
|
2011-06-24 22:53:21 +02:00
|
|
|
|
2014-10-09 22:44:56 +02:00
|
|
|
env_request_method.clear();
|
|
|
|
env_request_uri.clear();
|
|
|
|
env_http_cookie.clear();
|
|
|
|
env_http_host.clear();
|
|
|
|
env_http_user_agent.clear();
|
|
|
|
env_http_accept_encoding.clear();
|
2022-02-01 18:44:23 +01:00
|
|
|
env_http_accept.clear();
|
2022-02-02 18:20:32 +01:00
|
|
|
env_http_accept_language.clear();
|
2014-10-09 22:44:56 +02:00
|
|
|
env_fcgi_role.clear();
|
|
|
|
env_content_type.clear();
|
|
|
|
env_https.clear();
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
item_tab.clear();
|
2008-12-10 05:42:49 +01:00
|
|
|
item.Clear();
|
2021-04-09 17:50:58 +02:00
|
|
|
item.set_connector(nullptr);
|
2010-08-10 22:43:38 +02:00
|
|
|
dir_tab.clear();
|
2011-01-20 19:37:51 +01:00
|
|
|
last_item = &item;
|
2008-12-30 02:05:03 +01:00
|
|
|
is_item = false;
|
2021-06-20 20:47:59 +02:00
|
|
|
function = nullptr;
|
2010-08-10 22:43:38 +02:00
|
|
|
param_tab.clear();
|
2011-07-29 00:18:10 +02:00
|
|
|
anchor.clear();
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
send_bin_stream = false;
|
|
|
|
send_main_stream = false;
|
2021-10-13 01:27:14 +02:00
|
|
|
send_all_frames = false;
|
2022-02-01 18:44:23 +01:00
|
|
|
send_frames.clear();
|
|
|
|
|
|
|
|
use_ezc_engine = false;
|
|
|
|
serialize_models = false;
|
|
|
|
|
|
|
|
accept_mime_types.clear();
|
|
|
|
container_type = ContainerType::container_raw;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-02-28 01:08:10 +01:00
|
|
|
status = WINIX_ERR_OK;
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
http_status = Header::status_200_ok;
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2009-10-08 19:59:10 +02:00
|
|
|
browser_msie = false;
|
2009-11-17 02:04:01 +01:00
|
|
|
redirect_to.clear();
|
2011-07-07 19:02:14 +02:00
|
|
|
redirect_type = 303;
|
2010-02-19 00:30:22 +01:00
|
|
|
x_sendfile.clear();
|
|
|
|
send_as_attachment = false;
|
2011-09-07 00:46:15 +02:00
|
|
|
|
|
|
|
using_ssl = false;
|
2021-05-31 10:58:34 +02:00
|
|
|
is_htmx_request = false;
|
2012-02-17 06:19:24 +01:00
|
|
|
|
|
|
|
start_time = 0;
|
2012-05-19 17:14:35 +02:00
|
|
|
start_date.Clear();
|
2012-04-22 20:23:44 +02:00
|
|
|
|
2021-06-24 15:33:44 +02:00
|
|
|
timespec_req_start.tv_sec = 0;
|
|
|
|
timespec_req_start.tv_nsec = 0;
|
|
|
|
timespec_req_stop.tv_sec = 0;
|
|
|
|
timespec_req_stop.tv_nsec = 0;
|
|
|
|
timespec_req_diff.tv_sec = 0;
|
|
|
|
timespec_req_diff.tv_nsec = 0;
|
|
|
|
|
|
|
|
timespec_ezc_engine_start.tv_sec = 0;
|
|
|
|
timespec_ezc_engine_start.tv_nsec = 0;
|
|
|
|
timespec_ezc_engine_stop.tv_sec = 0;
|
|
|
|
timespec_ezc_engine_stop.tv_nsec = 0;
|
|
|
|
|
2012-04-22 20:23:44 +02:00
|
|
|
subdomain.clear();
|
2021-06-16 18:07:44 +02:00
|
|
|
models.Clear();
|
2012-08-26 21:53:47 +02:00
|
|
|
|
2013-11-14 21:59:23 +01:00
|
|
|
out_bin_stream.clear();
|
2012-09-11 07:19:45 +02:00
|
|
|
|
2012-08-26 21:53:47 +02:00
|
|
|
gen_trim_white = false;
|
|
|
|
gen_skip_new_line = false;
|
|
|
|
gen_use_special_chars = false;
|
2012-10-27 09:44:26 +02:00
|
|
|
|
|
|
|
ip = 0;
|
2018-05-01 13:22:55 +02:00
|
|
|
ip_str.clear();
|
2013-03-26 01:04:01 +01:00
|
|
|
use_200_status_for_not_found_and_permission_denied = false;
|
2021-01-27 18:31:48 +01:00
|
|
|
|
|
|
|
html_template.clear();
|
2021-10-13 01:27:14 +02:00
|
|
|
use_html_filter = false;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-17 06:19:24 +01:00
|
|
|
void Request::RequestStarts()
|
|
|
|
{
|
|
|
|
// clearing it is better to use at the end of a request
|
|
|
|
// so starting is much faster
|
2021-06-24 15:33:44 +02:00
|
|
|
clock_gettime(CLOCK_REALTIME, ×pec_req_start);
|
|
|
|
timespec_req_stop = timespec_req_start;
|
2012-02-17 06:19:24 +01:00
|
|
|
|
2021-06-24 15:33:44 +02:00
|
|
|
start_time = timespec_req_start.tv_sec;
|
2012-05-19 17:14:35 +02:00
|
|
|
start_date = start_time;
|
2012-02-17 06:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2021-06-24 15:33:44 +02:00
|
|
|
void Request::RequestEnds()
|
|
|
|
{
|
|
|
|
clock_gettime(CLOCK_REALTIME, ×pec_req_stop);
|
|
|
|
calculate_timespec_diff(timespec_req_start, timespec_req_stop, timespec_req_diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
void Request::PrepareAnswerType()
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
CheckAcceptHeader();
|
|
|
|
CheckContainerParameter();
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
serialize_models = (container_type != ContainerType::container_raw);
|
2021-10-13 01:27:14 +02:00
|
|
|
send_all_frames = (ParamValuep(config->request_all_frames_parameter) != nullptr);
|
2022-02-01 18:44:23 +01:00
|
|
|
send_main_stream = (ParamValuep(config->request_main_stream_parameter) != nullptr);
|
2021-10-13 01:27:14 +02:00
|
|
|
use_html_filter = config->html_filter;
|
2022-02-01 18:44:23 +01:00
|
|
|
PrepareFrameNames();
|
|
|
|
|
|
|
|
if( container_type == ContainerType::container_raw && !send_all_frames && send_frames.empty() )
|
|
|
|
{
|
|
|
|
send_main_stream = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
use_ezc_engine = send_main_stream || send_all_frames || !send_frames.empty();
|
|
|
|
}
|
2021-10-13 01:27:14 +02:00
|
|
|
|
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
void Request::CheckAcceptHeader()
|
|
|
|
{
|
|
|
|
if( !accept_mime_types.empty() )
|
|
|
|
{
|
|
|
|
bool found = false;
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
for(HeaderValue & h: accept_mime_types)
|
|
|
|
{
|
|
|
|
if( h.value == Header::text_html || h.value == Header::application_xhtml_xml ||
|
|
|
|
h.value == Header::text_all || h.value == Header::all_all)
|
|
|
|
{
|
|
|
|
container_type = ContainerType::container_raw;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( h.value == Header::application_json || h.value == Header::application_all )
|
|
|
|
{
|
|
|
|
container_type = ContainerType::container_json;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( h.value == Header::application_xml )
|
|
|
|
{
|
|
|
|
container_type = ContainerType::container_xml;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( h.value == Header::text_csv )
|
|
|
|
{
|
|
|
|
container_type = ContainerType::container_csv;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( !found )
|
|
|
|
{
|
|
|
|
Log * log = get_logger();
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( log )
|
|
|
|
{
|
|
|
|
(*log) << log2 << "App: an unknown " << Header::accept << " headers: ";
|
|
|
|
HeaderValue::log_values(accept_mime_types, *log);
|
|
|
|
(*log) << " (skipping)" << logend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
|
|
|
|
void Request::CheckContainerParameter()
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
|
|
|
std::wstring * container = ParamValuep(L"container");
|
|
|
|
|
|
|
|
if( container )
|
|
|
|
{
|
|
|
|
// IMPROVEME do a plugin call here
|
|
|
|
// if a plugin can consume this then don't check text/json/xml/csv and just return true
|
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( *container == L"raw" )
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
container_type = ContainerType::container_raw;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if( *container == L"json" )
|
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
container_type = ContainerType::container_json;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if( *container == L"xml" )
|
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
container_type = ContainerType::container_xml;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if( *container == L"csv" )
|
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
container_type = ContainerType::container_csv;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log * log = get_logger();
|
|
|
|
|
|
|
|
if( log )
|
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
(*log) << log2 << "App: an unknown container url parameter: " << *container << " (skipping)" << logend;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
void Request::PrepareFrameNames()
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
Config * config = get_config();
|
|
|
|
Log * log = get_logger();
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( config && log )
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
const std::wstring & frame = ParamValue(config->request_frame_parameter);
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( frame.size() <= config->request_frame_parameter_max_length )
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
send_frames.clear();
|
|
|
|
slice_by(frame, ',', send_frames);
|
|
|
|
std::sort(send_frames.begin(), send_frames.end());
|
|
|
|
auto frames_end = std::unique(send_frames.begin(), send_frames.end());
|
|
|
|
send_frames.erase(frames_end, send_frames.end());
|
2021-10-13 01:27:14 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
if( send_frames.size() > config->request_frame_parameter_max_frames )
|
2021-10-13 01:27:14 +02:00
|
|
|
{
|
2022-02-01 18:44:23 +01:00
|
|
|
send_frames.clear();
|
|
|
|
(*log) << log2 << "Request: the number of frames exceeds " << config->request_frame_parameter_max_frames
|
|
|
|
<< " (skipping frames)" << logend;
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
}
|
2022-02-01 18:44:23 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
(*log) << log2 << "Request: the length of the frame url parameter exceeds " << config->request_frame_parameter_max_length
|
|
|
|
<< " characters (skiping frames)" << logend;
|
|
|
|
}
|
2021-10-13 01:27:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
// add such a method to Space
|
|
|
|
bool Request::AddPostVar(const wchar_t * name, const wchar_t * value)
|
|
|
|
{
|
|
|
|
bool status = false;
|
|
|
|
pt::Space * space_value = post_in.get_space(name);
|
|
|
|
Log * log = get_logger();
|
2021-10-13 01:27:14 +02:00
|
|
|
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
if( space_value )
|
|
|
|
{
|
|
|
|
if( space_value->is_table() )
|
|
|
|
{
|
|
|
|
if( space_value->table_size() < WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE )
|
|
|
|
{
|
|
|
|
status = true;
|
|
|
|
space_value->add(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( log )
|
|
|
|
{
|
|
|
|
(*log) << log1 << "App: more than " << WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE << " post variables in a table " << name << " (skipping)" << logend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = true;
|
|
|
|
pt::Space new_table;
|
|
|
|
new_table.add(std::move(*space_value));
|
|
|
|
new_table.add(value);
|
|
|
|
space_value->set(std::move(new_table));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( post_in.object_size() < WINIX_POSTTABLE_MAXSIZE )
|
|
|
|
{
|
|
|
|
post_in.add(name, value);
|
|
|
|
status = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( log )
|
|
|
|
{
|
|
|
|
(*log) << log1 << "App: more than " << WINIX_POSTTABLE_MAXSIZE << " post variables (skipping)" << logend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Request::AddPostVar(const std::wstring & name, const std::wstring & value)
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return AddPostVar(name.c_str(), value.c_str());
|
|
|
|
}
|
2008-12-10 05:42:49 +01:00
|
|
|
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
|
|
|
|
bool Request::IsPostVar(const wchar_t * var)
|
|
|
|
{
|
|
|
|
return post_in.has_key(var);
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
bool Request::IsPostVar(const std::wstring & var)
|
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return post_in.has_key(var);
|
2011-11-25 05:51:55 +01:00
|
|
|
}
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring & Request::PostVar(const wchar_t * var)
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
std::wstring * value = post_in.get_wstr(var);
|
|
|
|
|
|
|
|
if( value )
|
|
|
|
return *value;
|
|
|
|
|
|
|
|
return str_empty;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
const std::wstring & Request::PostVar(const std::wstring & var)
|
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return PostVar(var.c_str());
|
2011-11-25 05:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool Request::PostVar(const wchar_t * var, std::wstring & result)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
std::wstring * value = post_in.get_wstr(var);
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
if( value )
|
|
|
|
{
|
|
|
|
result = *value;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
else
|
2009-11-17 00:36:38 +01:00
|
|
|
{
|
|
|
|
result.clear();
|
|
|
|
}
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
|
|
|
|
return found;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
2009-11-17 02:04:01 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
bool Request::PostVar(const std::wstring & var, std::wstring & result)
|
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return PostVar(var.c_str(), result);
|
2011-11-25 05:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring * Request::PostVarp(const wchar_t * var)
|
2010-09-30 22:58:20 +02:00
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return post_in.get_wstr(var);
|
2010-09-30 22:58:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-04 19:51:43 +02:00
|
|
|
std::wstring * Request::PostVarp(const std::wstring & var)
|
|
|
|
{
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
return post_in.get_wstr(var.c_str());
|
2009-12-09 01:42:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-22 23:26:56 +02:00
|
|
|
std::wstring * Request::ParamValuep(const wchar_t * param_name)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2018-04-22 23:26:56 +02:00
|
|
|
ParamTab::iterator i;
|
2010-11-21 01:19:17 +01:00
|
|
|
|
|
|
|
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
|
|
|
{
|
|
|
|
if( i->name == param_name )
|
2018-04-22 23:26:56 +02:00
|
|
|
return &i->value;
|
2010-11-21 01:19:17 +01:00
|
|
|
}
|
|
|
|
|
2018-04-22 23:26:56 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2010-11-21 01:19:17 +01:00
|
|
|
|
2018-04-22 23:26:56 +02:00
|
|
|
std::wstring * Request::ParamValuep(const std::wstring & param_name)
|
2010-11-21 01:19:17 +01:00
|
|
|
{
|
2018-04-22 23:26:56 +02:00
|
|
|
ParamTab::iterator i;
|
2010-11-21 01:19:17 +01:00
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-07-04 22:27:14 +02:00
|
|
|
if( i->name == param_name )
|
2018-04-22 23:26:56 +02:00
|
|
|
return &i->value;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
2018-04-22 23:26:56 +02:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Request::IsParam(const wchar_t * param_name)
|
|
|
|
{
|
|
|
|
return ParamValuep(param_name) != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Request::IsParam(const std::wstring & param_name)
|
|
|
|
{
|
|
|
|
return ParamValuep(param_name) != nullptr;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring & Request::ParamValue(const wchar_t * param_name)
|
2010-07-04 22:27:14 +02:00
|
|
|
{
|
2018-04-22 23:26:56 +02:00
|
|
|
const std::wstring * val = ParamValuep(param_name);
|
|
|
|
|
|
|
|
if( val != nullptr )
|
|
|
|
return *val;
|
2010-07-04 22:27:14 +02:00
|
|
|
|
2018-04-22 23:26:56 +02:00
|
|
|
return str_empty;
|
2010-07-04 22:27:14 +02:00
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2011-02-11 22:37:28 +01:00
|
|
|
const std::wstring & Request::ParamValue(const std::wstring & param_name)
|
|
|
|
{
|
2018-04-22 23:26:56 +02:00
|
|
|
const std::wstring * val = ParamValuep(param_name);
|
|
|
|
|
|
|
|
if( val != nullptr )
|
|
|
|
return *val;
|
|
|
|
|
|
|
|
return str_empty;
|
2011-02-11 22:37:28 +01:00
|
|
|
}
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
|
2022-04-26 23:41:56 +02:00
|
|
|
void Request::AddParam(const std::wstring & param_name, const std::wstring & param_value)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
ParamTab::iterator i;
|
|
|
|
|
|
|
|
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
|
|
|
{
|
|
|
|
if( i->name == param_name )
|
|
|
|
{
|
|
|
|
i->value = param_value;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !found )
|
|
|
|
{
|
|
|
|
Param param;
|
|
|
|
param.name = param_name;
|
|
|
|
param.value = param_value;
|
|
|
|
param_tab.push_back(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Request::AddParam(const wchar_t * param_name, const wchar_t * param_value)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
ParamTab::iterator i;
|
|
|
|
|
|
|
|
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
|
|
|
{
|
|
|
|
if( i->name == param_name )
|
|
|
|
{
|
|
|
|
i->value = param_value;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !found )
|
|
|
|
{
|
|
|
|
Param param;
|
|
|
|
param.name = param_name;
|
|
|
|
param.value = param_value;
|
|
|
|
param_tab.push_back(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Request::RemoveParam(const wchar_t * param_name)
|
|
|
|
{
|
|
|
|
ParamTab::iterator i;
|
|
|
|
|
|
|
|
for(size_t i=0 ; i < param_tab.size() ; )
|
|
|
|
{
|
|
|
|
if( param_tab[i].name == param_name )
|
|
|
|
{
|
|
|
|
param_tab.erase(param_tab.begin() + i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Request::RemoveParam(const std::wstring & param_name)
|
|
|
|
{
|
|
|
|
ParamTab::iterator i;
|
|
|
|
|
|
|
|
for(size_t i=0 ; i < param_tab.size() ; )
|
|
|
|
{
|
|
|
|
if( param_tab[i].name == param_name )
|
|
|
|
{
|
|
|
|
param_tab.erase(param_tab.begin() + i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
|
2021-07-01 23:34:49 +02:00
|
|
|
void Request::current_dir(morm::Wrapper & wrapper)
|
2021-06-18 19:18:13 +02:00
|
|
|
{
|
2021-07-01 23:34:49 +02:00
|
|
|
wrapper.model = dir_tab.back();
|
2021-06-18 19:18:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-03 01:14:53 +02:00
|
|
|
void Request::last_item_wrapper(morm::Wrapper & wrapper)
|
|
|
|
{
|
|
|
|
wrapper.model = last_item;
|
|
|
|
}
|
2021-06-18 19:18:13 +02:00
|
|
|
|
2021-06-24 15:33:44 +02:00
|
|
|
|
2022-02-01 18:44:23 +01:00
|
|
|
bool Request::has_frame(const wchar_t * frame)
|
|
|
|
{
|
|
|
|
for(std::wstring & f: send_frames)
|
|
|
|
{
|
|
|
|
if( f == frame )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Request::has_frame(const std::wstring & frame)
|
|
|
|
{
|
|
|
|
for(std::wstring & f: send_frames)
|
|
|
|
{
|
|
|
|
if( f == frame )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2022-05-30 01:29:18 +02:00
|
|
|
void Request::http_status_error_title(EzcEnv & env)
|
|
|
|
{
|
|
|
|
pt::WTextStream str;
|
|
|
|
str << L"http_error_" << http_status << L"_title";
|
|
|
|
|
|
|
|
const std::wstring & msg = TemplatesFunctions::locale.Get(str);
|
|
|
|
env.out << msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Request::http_status_error_description(EzcEnv & env)
|
|
|
|
{
|
|
|
|
pt::WTextStream str;
|
|
|
|
str << L"http_error_" << http_status << L"_msg";
|
|
|
|
|
|
|
|
const std::wstring & msg = TemplatesFunctions::locale.Get(str);
|
|
|
|
env.out << msg;
|
|
|
|
}
|
2022-02-01 18:44:23 +01:00
|
|
|
|
2021-06-24 15:33:44 +02:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|