本文整理汇总了C++中Http::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Http::end方法的具体用法?C++ Http::end怎么用?C++ Http::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
int exec() {
vf array;
// query fortunes
mysql_query(db.connection(), "SELECT id, message FROM Fortune;");
MYSQL_RES *sqlres = mysql_store_result(db.connection());
if (!sqlres) throw runtime_error(mysql_error(db.connection()));
MYSQL_ROW row;
while( (row=mysql_fetch_row(sqlres)) ){
array.push_back(Fortune(atoi(row[0]),row[1]));
}
mysql_free_result(sqlres);
// add on the fly
array.push_back(Fortune(0,"Additional fortune added at request time."));
// sort
sort(array.begin(),array.end());
// output html
res << "<!DOCTYPE html>"
"<html>"
"<head><title>Fortunes</title></head>"
"<body>"
"<table>"
"<tr><th>id</th><th>message</th></tr>";
for(unsigned z=0;z<array.size();++z) {
Fortune &az = array[z];
res << "<tr>"
"<td>" << az.id << "</td>"
"<td>" << xml::escape(az.message) << "</td>"
"</tr>";
}
res << "</table>"
"</body>"
"</html>";
return res.end();
}
示例2: exec
int exec() {
id = rand()%10000;
// reset statement for reuse
if(mysql_stmt_reset(stmt)) throw runtime_error(mysql_stmt_error(stmt));
// create and use input parameter
memset(param, 0, sizeof(param));
param[0].buffer_type = MYSQL_TYPE_LONG;
param[0].buffer = (char *)&id;
param[0].buffer_length = sizeof(id);
param[0].is_null = 0;
param[0].length = NULL;
if(mysql_stmt_bind_param(stmt,param)) throw runtime_error(mysql_stmt_error(stmt));
// create and fill result buffer
memset(results, 0, sizeof(results));
results[0].buffer_type= MYSQL_TYPE_LONG;
results[0].buffer = &randomNumber;
results[0].buffer_length = sizeof(randomNumber);
results[0].is_null = 0;
results[0].length = &len1;
if(mysql_stmt_bind_result(stmt, results)) throw runtime_error(mysql_stmt_error(stmt));
// execute statement
if(mysql_stmt_execute(stmt)) throw runtime_error(mysql_stmt_error(stmt));
if(mysql_stmt_fetch(stmt)) randomNumber = 0;
// output json
JsonObj obj;
obj.add("id",id);
obj.add("randomNumber",randomNumber);
res << obj.to_s();
return res.end();
}
示例3: exec
int exec() {
int n = res.get_i("queries=");
if(n<1) n = 1;
if(n>500) n = 500;
vw array;
while(n--) {
id = rand()%10000;
newNumber = rand()%10000+1;
// reset statement for reuse
if(mysql_stmt_reset(stmt)) throw runtime_error(mysql_stmt_error(stmt));
if(mysql_stmt_reset(ustmt)) throw runtime_error(mysql_stmt_error(ustmt));
// create and use input parameter
memset(param, 0, sizeof(param));
param[0].buffer_type = MYSQL_TYPE_LONG;
param[0].buffer = (char *)&id;
param[0].buffer_length = sizeof(id);
param[0].is_null = 0;
param[0].length = NULL;
if(mysql_stmt_bind_param(stmt,param)) throw runtime_error(mysql_stmt_error(stmt));
// create and fill result buffer
memset(results, 0, sizeof(results));
results[0].buffer_type= MYSQL_TYPE_LONG;
results[0].buffer = &randomNumber;
results[0].buffer_length = sizeof(randomNumber);
results[0].is_null = 0;
results[0].length = &len1;
if(mysql_stmt_bind_result(stmt, results)) throw runtime_error(mysql_stmt_error(stmt));
// create and use update parameter
memset(param_update, 0, sizeof(param_update));
param_update[0].buffer_type = MYSQL_TYPE_LONG;
param_update[0].buffer = (char *)&newNumber;
param_update[0].buffer_length = sizeof(newNumber);
param_update[0].is_null = 0;
param_update[0].length = 0;
param_update[1].buffer_type = MYSQL_TYPE_LONG;
param_update[1].buffer = (char *)&id;
param_update[1].buffer_length = sizeof(id);
param_update[1].is_null = 0;
param_update[1].length = 0;
// execute statement
if(mysql_stmt_execute(stmt)) throw runtime_error(mysql_stmt_error(stmt));
if(mysql_stmt_bind_param(ustmt,param_update)) throw runtime_error(mysql_stmt_error(ustmt));
if(mysql_stmt_fetch(stmt)) randomNumber = 0;
// add to array (required by specification)
array.push_back(World(id,newNumber));
}
// output json
res << '[';
for(unsigned z=0;z<array.size();++z) {
if(z>0) res << ',';
World &az = array[z];
JsonObj obj;
obj.add("id",az.id);
obj.add("randomNumber",az.randomNumber);
res << obj.to_s();
}
res << ']';
return res.end();
}
示例4: exec
int exec() {
JsonObj obj;
obj.add("message","Hello, World!");
res << obj.to_s();
return res.end();
}