本文整理汇总了C++中URI::host方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::host方法的具体用法?C++ URI::host怎么用?C++ URI::host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::host方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: icase_equal
bool operator == (const URI& lhs, const URI& rhs) noexcept {
return icase_equal(lhs.scheme(), rhs.scheme())
and (lhs.userinfo() == rhs.userinfo())
and icase_equal(lhs.host(), rhs.host())
and lhs.port() == rhs.port()
and lhs.path() == rhs.path()
and lhs.query() == rhs.query()
and lhs.fragment() == rhs.fragment();
}
示例2: populate_from_url
void Client::populate_from_url(Request& req, const URI& url)
{
// Set uri path (default "/")
req.set_uri((!url.path().empty()) ? URI{url.path()} : URI{"/"});
// Set Host: host(:port)
const auto port = url.port();
req.header().set_field(header::Host,
(port != 0xFFFF and port != 80) ?
url.host().to_string() + ":" + std::to_string(port)
: url.host().to_string()); // to_string madness
}
示例3: GetScaffold
Variant BaseVariantAppProtocolHandler::GetScaffold(string uriString) {
//1. Search in the cache first
if (_urlCache.HasKey(uriString)) {
return _urlCache[uriString];
}
//2. Build it
Variant result;
//3. Split the URL into components
URI uri;
if (!URI::FromString(uriString, true, uri)) {
FATAL("Invalid url: %s", STR(uriString));
return Variant();
}
//6. build the end result
result["username"] = uri.userName();
result["password"] = uri.password();
result["host"] = uri.host();
result["ip"] = uri.ip();
result["port"] = uri.port();
result["document"] = uri.fullDocumentPath();
result["applicationName"] = GetApplication()->GetName();
//7. Save it in the cache
_urlCache[uriString] = result;
//8. Done
return result;
}
示例4: request
void Client::request(Method method, URI url, Header_set hfields, std::string data, Response_handler cb, Options options)
{
using namespace std;
tcp_.stack().resolve(
url.host().to_string(),
ResolveCallback::make_packed(
[
this,
method,
url{move(url)},
hfields{move(hfields)},
data{move(data)},
cb{move(cb)},
opt{move(options)}
] (auto ip)
{
// Host resolved
if(ip != 0)
{
// setup request with method and headers
auto req = create_request(method);
*req << hfields;
// Set Host & path from url
populate_from_url(*req, url);
// Add data and content length
add_data(*req, data);
// Default to port 80 if non given
const uint16_t port = (url.port() != 0xFFFF) ? url.port() : 80;
send(move(req), {ip, port}, move(cb), move(opt));
}
else
{
cb({Error::RESOLVE_HOST}, nullptr);
}
})
);
}