本文整理汇总了C++中URI::protocol方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::protocol方法的具体用法?C++ URI::protocol怎么用?C++ URI::protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::protocol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cookiesForRequest
void CookieJar::cookiesForRequest(
const URI &request,
std::string &headers,
time_t now)
{
loadDomainCookies(request.server());
loadDomainCookies(topLevel(request.server()));
// printf("cookiesForRequest: %s \n",request.asString().c_str());
string domain(request.server());
// find a cookie in the jar that corresponds to the requested domain...
string tmp("Cookie: ");
bool needSep(false);
const static string sep("; ");
bool haveExpired(false);
std::vector<Cookie *>::const_iterator it(m_cookies.begin());
for (; it != m_cookies.end(); ++it)
{
Cookie *c(*it);
if (c->name() == DOMAIN_STR)
continue;
if (c->matchesDomain(domain)) {
if (c->expired(now)) {
haveExpired = true;
continue;
}
if (not c->path().empty())
{
// check to see if the requested path is a sub dir of path
string value = c->path();
string file = request.fileName();
size_t pos = file.find(value);
if (pos != 0)
{
continue;
}
}
// do not send secure cookies to unsecure domains
if (c->secure() and request.protocol() != URI::HTTPS_PROTOCOL)
{
continue;
}
if (needSep)
{
tmp += sep;
}
string value(c->value());
bool needQuotes = value.find_first_of(" ")!=string::npos;
tmp += c->name();
tmp += "=";
if (needQuotes) {
tmp += "\"";
}
tmp += c->value();
if (needQuotes) {
tmp += "\"";
}
needSep = true;
}
}
if (needSep) {
tmp += "\r\n";
headers = tmp;
}
if (haveExpired) {
gcExpiredCookies(now);
}
}