add Request::AddPostVar(pt::Space & space, const wchar_t * name)
This commit is contained in:
parent
5f77ce619e
commit
d3a440fa0a
|
@ -418,45 +418,44 @@ void Request::PrepareFrameNames()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// add such a method to Space
|
||||
bool Request::AddPostVar(const wchar_t * name, const wchar_t * value)
|
||||
pt::Space * Request::AddPostVar(pt::Space & space, const wchar_t * name)
|
||||
{
|
||||
bool status = false;
|
||||
pt::Space * space_value = post_in.get_space(name);
|
||||
pt::Space * space_value = space.get_space(name);
|
||||
pt::Space * new_space = nullptr;
|
||||
Log * log = get_logger();
|
||||
|
||||
if( space_value )
|
||||
{
|
||||
if( space_value->is_table() )
|
||||
{
|
||||
if( space_value->table_size() < WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE )
|
||||
if( space_value->table_size() < WINIX_POSTTABLE_VALUE_TABLE_MAXSIZE )
|
||||
{
|
||||
status = true;
|
||||
space_value->add(value);
|
||||
new_space = &space_value->add_empty_space();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( log )
|
||||
{
|
||||
(*log) << log1 << "Request: more than " << WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE << " post variables in a table " << name << " (skipping)" << logend;
|
||||
(*log) << log1 << "Request: more than " << WINIX_POSTTABLE_VALUE_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);
|
||||
new_space = &new_table.add_empty_space();
|
||||
space_value->set(std::move(new_table));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( post_in.object_size() < WINIX_POSTTABLE_MAXSIZE )
|
||||
if( space.object_size() < WINIX_POSTTABLE_MAXSIZE )
|
||||
{
|
||||
post_in.add(name, value);
|
||||
status = true;
|
||||
new_space = &space.add_empty_space(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -467,7 +466,21 @@ bool Request::AddPostVar(const wchar_t * name, const wchar_t * value)
|
|||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
return new_space;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::AddPostVar(const wchar_t * name, const wchar_t * value)
|
||||
{
|
||||
pt::Space * new_space = AddPostVar(post_in, name);
|
||||
|
||||
if( new_space )
|
||||
{
|
||||
new_space->set(value);
|
||||
}
|
||||
|
||||
return new_space != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -481,6 +481,7 @@ public:
|
|||
void RemoveParam(const wchar_t * param_name);
|
||||
void RemoveParam(const std::wstring & param_name);
|
||||
|
||||
pt::Space * AddPostVar(pt::Space & space, const wchar_t * name);
|
||||
bool AddPostVar(const wchar_t * name, const wchar_t * value);
|
||||
bool AddPostVar(const std::wstring & name, const std::wstring & value);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Winix
|
|||
|
||||
// may move to config?
|
||||
#define WINIX_POSTTABLE_MAXSIZE 1024
|
||||
#define WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE 1024
|
||||
#define WINIX_POSTTABLE_VALUE_TABLE_MAXSIZE 1024
|
||||
|
||||
|
||||
struct PostFile
|
||||
|
|
Loading…
Reference in New Issue