本文整理汇总了C++中CCgiContext::GetSelfURL方法的典型用法代码示例。如果您正苦于以下问题:C++ CCgiContext::GetSelfURL方法的具体用法?C++ CCgiContext::GetSelfURL怎么用?C++ CCgiContext::GetSelfURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCgiContext
的用法示例。
在下文中一共展示了CCgiContext::GetSelfURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessRequest
int CCgiSampleApplication::ProcessRequest(CCgiContext& ctx)
{
// Parse, verify, and look at cmd-line and CGI parameters via "CArgs"
// (optional)
x_LookAtArgs();
// Given "CGI context", get access to its "HTTP request" and
// "HTTP response" sub-objects
const CCgiRequest& request = ctx.GetRequest();
CCgiResponse& response = ctx.GetResponse();
// Try to retrieve the message ('message=...') from the HTTP request.
// NOTE: the case sensitivity was turned off in Init().
bool is_message = false;
string message = request.GetEntry("message", &is_message);
if ( is_message ) {
message = "'" + message + "'";
} else {
message = "<NONE>";
}
int iters = 5;
for(int i = 0; i < iters; ++i) {
PutProgressMessage( "Iteration " + NStr::IntToString(i)
+ " of " + NStr::IntToString(iters));
SleepSec(5);
}
string this_host = CSocketAPI::gethostname();
// Create a HTML page (using template HTML file "cgi_sample.html")
auto_ptr<CHTMLPage> page;
try {
page.reset(new CHTMLPage("Sample Remote CGI", "rcgi_sample.html"));
} catch (exception& e) {
ERR_POST("Failed to create Sample CGI HTML page: " << e.what());
return 2;
}
// Register substitution for the template parameters <@[email protected]> and
// <@[email protected]>
try {
CHTMLPlainText* host = new CHTMLPlainText(this_host);
page->AddTagMap("HOST", host);
CHTMLPlainText* text = new CHTMLPlainText(message);
page->AddTagMap("MESSAGE", text);
CHTMLPlainText* self_url = new CHTMLPlainText(ctx.GetSelfURL());
page->AddTagMap("SELF_URL", self_url);
CHTMLPlainText* date = new CHTMLPlainText(
GetFastLocalTime().AsString("D B Y, h:m:s"));
page->AddTagMap("DATE", date);
}
catch (exception& e) {
ERR_POST("Failed to populate Sample CGI HTML page: " << e.what());
return 3;
}
// Compose and flush the resultant HTML page
try {
response.SetHeaderValue("Pragma", "no-cache");
response.SetHeaderValue("Cache-Control", "no-cache");
response.WriteHeader();
page->Print(response.out(), CNCBINode::eHTML);
} catch (exception& e) {
ERR_POST("Failed to compose/send Sample CGI HTML page: " << e.what());
return 4;
}
return 0;
}