changed: if there is no body we do not parse application/json to space

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1183 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2019-03-25 00:51:51 +00:00
parent 4c2efc08fd
commit 177e58da4e
1 changed files with 14 additions and 7 deletions

View File

@ -1095,14 +1095,21 @@ void App::ReadPostJson()
}
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 )
if( !post_buffer.empty() )
{
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?)
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?)
}
}
else
{
log << log3 << "App: input body empty (skipping parsing)" << logend;
}
}