本文整理汇总了C++中HttpServer::ProcessPostRequest方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpServer::ProcessPostRequest方法的具体用法?C++ HttpServer::ProcessPostRequest怎么用?C++ HttpServer::ProcessPostRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpServer
的用法示例。
在下文中一共展示了HttpServer::ProcessPostRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HttpCallback
void HttpServer::HttpCallback(
struct mg_connection *conn,
const struct mg_request_info *request_info,
void *user_data
)
{
const char * url = request_info->uri;
const char * query = request_info->query_string;
HttpServer *This = (HttpServer*)user_data;
char *outdata=NULL;
int freer_type=0;
try
{
This->StartProcessingQuery(url);
char * content_type = "text/html";
bool page_generated=false;
if( strcmp(request_info->request_method,"GET")==0 )
{
page_generated = This->GenerateHtml( url, query, &outdata, &freer_type, &content_type );
}
else if( strcmp(request_info->request_method,"POST")==0 )
{
page_generated = This->ProcessPostRequest( url, query, request_info->post_data, request_info->post_data_len, &outdata, &freer_type, &content_type );
}
if( page_generated )
This->WriteHeader( conn, content_type );
else
This->PageNotFound( conn );
if( outdata!=NULL )
{
const int l = strlen(outdata);
if( l<8000 )
{
mg_printf( conn, "%s", outdata );
}
else
{
int tail=l;
int ipos=0;
while( tail>0 )
{
int chunk=8000;
if( tail<8000 )
chunk = tail;
char c = outdata[ipos+chunk];
outdata[ipos+chunk] = 0;
mg_printf( conn, "%s", outdata+ipos );
outdata[ipos+chunk] = c;
ipos += chunk;
tail -= chunk;
}
}
}
}
catch(...)
{
if( lem::LogFile::IsOpen() )
{
lem::MemFormatter mem;
mem.printf( "Inhandled exception in file %s line %d", __FILE__, __LINE__ );
lem::LogFile::Print( mem.string() );
}
}
try
{
switch( freer_type )
{
case 0: break;
case 1: delete[] outdata; break;
case 2: free(outdata); break;
}
}
catch(...)
{
if( lem::LogFile::IsOpen() )
{
lem::MemFormatter mem;
mem.printf( "Inhandled exception in file %s line %d", __FILE__, __LINE__ );
lem::LogFile::Print( mem.string() );
}
}
try
{
This->StartProcessingQuery(url);
}
catch(...)
{
if( lem::LogFile::IsOpen() )
{
//.........这里部分代码省略.........