|
|
|
@ -949,9 +949,48 @@ void App::LogAccess()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void App::ReadPostJson()
|
|
|
|
|
{
|
|
|
|
|
char buffer[1024];
|
|
|
|
|
const int buffer_len = sizeof(buffer) / sizeof(char) - 1;
|
|
|
|
|
int read_len;
|
|
|
|
|
|
|
|
|
|
post_json_parser.SetSpace(cur.request->post_in);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
while( read_len == buffer_len );
|
|
|
|
|
|
|
|
|
|
PT::JSONToSpaceParser::Status status = post_json_parser.ParseString(post_buffer.c_str());
|
|
|
|
|
post_buffer.clear();
|
|
|
|
|
|
|
|
|
|
if( status != PT::JSONToSpaceParser::ok )
|
|
|
|
|
{
|
|
|
|
|
log << log1 << "App: cannot parse the input stream as a JSON object, status: " << (int)status << logend;
|
|
|
|
|
cur.request->post_in.Clear();
|
|
|
|
|
// return an error (http error of some kind?)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void App::ReadPostVars()
|
|
|
|
|
{
|
|
|
|
|
if( cur.request->method == Request::post )
|
|
|
|
|
// CHECKME
|
|
|
|
|
// what about errors during parsing input?
|
|
|
|
|
|
|
|
|
|
if( cur.request->method == Request::post || cur.request->method == Request::delete_ )
|
|
|
|
|
{
|
|
|
|
|
if( IsSubStringNoCase(L"multipart/form-data", cur.request->env_content_type.c_str()) )
|
|
|
|
|
{
|
|
|
|
@ -959,7 +998,14 @@ void App::ReadPostVars()
|
|
|
|
|
post_multi_parser.Parse(fcgi_request.in, cur.request->post_tab, cur.request->post_file_tab);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if( IsSubStringNoCase(L"application/json", cur.request->env_content_type.c_str()) )
|
|
|
|
|
{
|
|
|
|
|
log << log3 << "App: post content type: application/json" << logend;
|
|
|
|
|
ReadPostJson();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// IMPROVE ME may to check a correct content-type header?
|
|
|
|
|
post_parser.Parse(fcgi_request.in, cur.request->post_tab);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|