本文整理汇总了C++中Content::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Content::execute方法的具体用法?C++ Content::execute怎么用?C++ Content::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
int Jupiter::HTTP::Server::Data::process_request(HTTPSession &session)
{
Jupiter::ReadableString::TokenizeResult<Jupiter::Reference_String> lines = Jupiter::ReferenceString::tokenize(session.request, STRING_LITERAL_AS_REFERENCE(ENDL));
HTTPCommand command = HTTPCommand::NONE_SPECIFIED;
Content *content = nullptr;
Jupiter::ReferenceString query_string;
Jupiter::ReferenceString first_token;
size_t index = 0;
size_t span;
auto get_line_offset = [&session, &lines](size_t index)
{
size_t offset = 0;
while (index != 0)
offset += lines.tokens[--index].size() + 2;
return offset;
};
while (index != lines.token_count)
{
Jupiter::ReferenceString &line = lines.tokens[index++];
// trim front-end spaces.
span = line.span(" "_jrs);
if (span != 0)
line.shiftRight(span);
if (line.isEmpty()) // end of http request
{
Jupiter::String result(256);
switch (command)
{
case HTTPCommand::GET:
case HTTPCommand::HEAD:
if (content != nullptr)
{
// 200 (success)
Jupiter::ReadableString *content_result = content->execute(query_string);
switch (session.version)
{
default:
case HTTPVersion::HTTP_1_0:
result = "HTTP/1.0 200 OK"_jrs ENDL;
break;
case HTTPVersion::HTTP_1_1:
result = "HTTP/1.1 200 OK"_jrs ENDL;
break;
}
result += "Date: "_jrs;
char *time_header = html_time();
result += time_header;
delete[] time_header;
result += ENDL;
result += "Server: "_jrs JUPITER_VERSION ENDL;
result += Jupiter::StringS::Format("Content-Length: %u" ENDL, content_result->size());
if (session.keep_alive)
result += "Connection: keep-alive"_jrs ENDL;
else
result += "Connection: close"_jrs ENDL;
result += "Content-Type: "_jrs;
if (content->type == nullptr)
result += Jupiter::HTTP::Content::Type::Text::PLAIN;
else
result += *content->type;
if (content->charset != nullptr)
{
result += "; charset="_jrs;
result += *content->charset;
}
result += ENDL;
if (content->language != nullptr)
{
result += "Content-Language: "_jrs;
result += *content->language;
result += ENDL;
}
result += ENDL;
if (command == HTTPCommand::GET)
result += *content_result;
if (content->free_result)
delete content_result;
session.sock.send(result);
}
else
{
// 404 (not found)
switch (session.version)
{
default:
//.........这里部分代码省略.........