本文整理汇总了C++中Cookie::setIsHttpOnly方法的典型用法代码示例。如果您正苦于以下问题:C++ Cookie::setIsHttpOnly方法的具体用法?C++ Cookie::setIsHttpOnly怎么用?C++ Cookie::setIsHttpOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cookie
的用法示例。
在下文中一共展示了Cookie::setIsHttpOnly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseOneCookie
//.........这里部分代码省略.........
break;
}
case 'M' :
case 'm' : {
if (length >= 7 && cookie.find("ax-age", tokenStartSvg + 1, false))
res->setMaxAge(parsedValue);
else {
LOG_ERROR("Invalid cookie %s (max-age)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'C' :
case 'c' : {
if (length >= 7 && cookie.find("omment", tokenStartSvg + 1, false))
// We do not have room for the comment part (and so do Mozilla) so just log the comment.
LOG(Network, "Comment %s for Cookie : %s\n", parsedValue.ascii().data(), cookie.ascii().data());
else {
LOG_ERROR("Invalid cookie %s (comment)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'V' :
case 'v' : {
if (length >= 7 && cookie.find("ersion", tokenStartSvg + 1, false)) {
if (parsedValue.toInt() != 1) {
LOG_ERROR("Cookie version %d not supported (only support version=1)", parsedValue.toInt());
delete res;
return 0;
}
} else {
LOG_ERROR("Invalid cookie %s (version)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'S' :
case 's' : {
// Secure is a standalone token ("Secure;")
if (length >= 6 && cookie.find("ecure", tokenStartSvg + 1, false))
res->setSecureFlag(true);
else {
LOG_ERROR("Invalid cookie %s (secure)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'H':
case 'h': {
// HttpOnly is a standalone token ("HttpOnly;")
if (length >= 8 && cookie.find("ttpOnly", tokenStartSvg + 1, false))
res->setIsHttpOnly(true);
else {
LOG_ERROR("Invalid cookie %s (HttpOnly)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
default : {
// If length == 0, we should be at the end of the cookie (case : ";\r") so ignore it
if (length) {
LOG_ERROR("Invalid token for cookie %s", cookie.ascii().data());
delete res;
return 0;
}
}
}
}
// Check if the cookie is valid with respect to the size limit/
if (!res->isUnderSizeLimit()) {
LOG_ERROR("Cookie %s is above the 4kb in length : REJECTED", cookie.ascii().data());
delete res;
return 0;
}
// If some pair was not provided, during parsing then apply some default value
// the rest has been done in the constructor.
// If no domain was provided, set it to the host
if (!res->domain() || !res->domain().length())
res->setDomain("." + m_defaultCookieURL.host());
// If no path was provided, set it to the host's path
if (!res->path() || !res->path().length())
res->setPath(m_defaultCookieURL.path());
return res;
}