本文整理汇总了C++中http_request::method方法的典型用法代码示例。如果您正苦于以下问题:C++ http_request::method方法的具体用法?C++ http_request::method怎么用?C++ http_request::method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http_request
的用法示例。
在下文中一共展示了http_request::method方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void details::http_listener_impl::handle_request(http_request msg)
{
// Specific method handler takes priority over general.
const method &mtd = msg.method();
if(m_supported_methods.count(mtd))
{
m_supported_methods[mtd](msg);
}
else if(mtd == methods::OPTIONS)
{
handle_options(msg);
}
else if(mtd == methods::TRCE)
{
handle_trace(msg);
}
else if(m_all_requests != nullptr)
{
m_all_requests(msg);
}
else
{
// Method is not supported.
// Send back a list of supported methods to the client.
http_response response(status_codes::MethodNotAllowed);
response.headers().add(U("Allow"), get_supported_methods());
msg.reply(response);
}
}
示例2: response
void
RestEngineUri::handle_delete(http_request request)
{
std::cout << request.method() << " : " << request.absolute_uri().path() << std::endl;
http_response response(status_codes::OK);
std::string resultstr("Not Supported");
std::pair<bool, std::string> result {true, std::string()};
make_response(response, resultstr, result);
request.reply(response);
}
示例3: validator
void
RestRollupsUri::handle_post(http_request request)
{
std::cout << request.method() << " : " << request.absolute_uri().path() << std::endl;
int rc = 0;
std::string resultstr;
std::pair<bool, std::string> result {true, std::string()};
char json[1024];
// extract json from request
snprintf(json, sizeof(json), "%s", request.extract_string(true).get().c_str());
std::cout << "JSON:\n" << json << std::endl;
rapidjson::Document document;
if (document.Parse(json).HasParseError())
{
rc = 1;
resultstr += "document invalid";
}
rapidjson::SchemaValidator validator(*_schema);
if (!document.Accept(validator)) {
rc = 1;
resultstr += get_schema_validation_error(&validator);
}
rapidjson::Value::MemberIterator name = document.FindMember("name");
rapidjson::Value::MemberIterator nocsv = document.FindMember("nocsv");
rapidjson::Value::MemberIterator quantity = document.FindMember("quantity");
rapidjson::Value::MemberIterator maxdroop = document.FindMember("maxDroop");
rapidjson::Value::MemberIterator maxsdroop_validation = document.FindMember("maxDroopMaxtoMinIOPSSection");
// Execute Ivy Engine command
if (rc == 0)
{
std::unique_lock<std::mutex> u_lk(goStatementMutex);
std::pair<int, std::string>
rslt = m_s.create_rollup(name->value.GetString(),
(nocsv != document.MemberEnd() ? nocsv->value.GetBool() : false),
false /* have_quantity_validation */,
(maxsdroop_validation != document.MemberEnd() ? maxsdroop_validation->value.GetBool() : false),
(quantity != document.MemberEnd() ? quantity->value.GetInt() : 1),
(maxdroop != document.MemberEnd() ? maxdroop->value.GetDouble() : 6.95323e-310));
}
http_response response(status_codes::OK);
make_response(response, resultstr, result);
request.reply(response);
}
示例4: response
void
RestRollupsUri::handle_get(http_request request)
{
std::cout << request.method() << " : " << request.absolute_uri().path() << std::endl;
http_response response(status_codes::OK);
std::string resultstr("Not Supported");
std::pair<bool, std::string> result {true, std::string()};
resultstr = m_s.show_rollup_structure();
make_response(response, resultstr, result);
request.reply(response);
return;
}
示例5: validator
void
RestEngineUri::handle_post(http_request request)
{
std::cout << request.method() << " : " << request.absolute_uri().path() << std::endl;
std::cout << request.method() << " : " << request.headers()["Cookie"] << std::endl;
int rc = 0;
std::string resultstr;
std::pair<bool, std::string> result {true, std::string()};
std::string cookie = request.headers()["Cookie"];
if (cookie != "session_cookie=" + _active_session_token)
{
//http_response response(status_codes::Locked);
//make_response(response, resultstr, result);
//request.reply(response);
//return;
}
if (!is_session_owner(request))
{
send_busy_response(request);
return;
}
ostringstream o;
o << "COOKIE:" << cookie << std::endl;
o << "ACTIVE COOKIE:" << _active_session_token << std::endl;
std::cout << o.str();
log (m_s.masterlogfile,o.str());
char json[1024];
// extract json from request
snprintf(json, sizeof(json), "%s", request.extract_string(true).get().c_str());
std::cout << "JSON:\n" << json << std::endl;
rapidjson::Document document;
if (document.Parse(json).HasParseError())
{
rc = 1;
resultstr += "document invalid";
}
rapidjson::SchemaValidator validator(*_schema);
if (!document.Accept(validator)) {
rc = 1;
resultstr += get_schema_validation_error(&validator);
}
std::string select_str;
std::string hosts_list;
const Value& hosts = document["hosts"];
json_to_host_list(hosts, hosts_list);
const Value& select = document["select"];
json_to_select_str(select, select_str);
// Execute Ivy Engine command
if (rc == 0)
{
std::unique_lock<std::mutex> u_lk(goStatementMutex);
std::string outputfolder = m_s.get("output_folder_root").second;
std::string testname = m_s.get("test_name").second;
result = m_s.startup(outputfolder, testname, m_s.ivyscript_filename, hosts_list, select_str);
}
http_response response(status_codes::OK);
make_response(response, resultstr, result);
request.reply(response);
}