本文整理汇总了C++中poco::net::HTTPServerRequest::getHost方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPServerRequest::getHost方法的具体用法?C++ HTTPServerRequest::getHost怎么用?C++ HTTPServerRequest::getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::net::HTTPServerRequest
的用法示例。
在下文中一共展示了HTTPServerRequest::getHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* virtual*/ void handleRequest(Poco::Net::HTTPServerRequest &req, Poco::Net::HTTPServerResponse &resp)
{
resp.setStatus(Poco::Net::HTTPResponse::HTTP_OK); //Sets the HTTP status code, Why?
resp.setContentType("text/html"); // set the content type of the message
ostream& out = resp.send(); //Returns an output stream for sending the response body. The returned stream is valid until the response object is destroyed.
out << "<h1>Hello world!</h1>" //Body of the repsonse
// << "<p>Count: " << ++count << "</p>"
<< "<p>Host: " << req.getHost() << "</p>" //Returns the value of the Host header field.
<< "<p>Method: " << req.getMethod() << "</p>"
<< "<p>URI: " << req.getURI() << "</p>";
out.flush();
cout << endl
//<< "Response sent for count=" << count
<< " Response sent for URI=" << req.getURI() << endl;
}