本文整理汇总了C++中ParsedCookie::isUnderSizeLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ ParsedCookie::isUnderSizeLimit方法的具体用法?C++ ParsedCookie::isUnderSizeLimit怎么用?C++ ParsedCookie::isUnderSizeLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedCookie
的用法示例。
在下文中一共展示了ParsedCookie::isUnderSizeLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseOneCookie
//.........这里部分代码省略.........
// We do not have room for the comment part (and so do Mozilla) so just log the comment.
LOG(Network, "Comment %s for ParsedCookie : %s\n", parsedValue.ascii().data(), cookie.ascii().data());
else
LOG_AND_DELETE("Invalid cookie %s (comment)", cookie.ascii().data());
break;
}
case 'V' :
case 'v' : {
if (length >= 7 && cookie.find("ersion", tokenStartSvg + 1, false)) {
// Although the out-of-dated Cookie Spec(RFC2965, http://tools.ietf.org/html/rfc2965) defined
// the value of version can only contain DIGIT, some random sites, e.g. https://devforums.apple.com
// would use double quotation marks to quote the digit. So we need to get rid of them for compliance.
if (parsedValue.length() > 1 && parsedValue[0] == '"' && parsedValue[parsedValue.length() - 1] == '"')
parsedValue = parsedValue.substring(1, parsedValue.length() - 2);
if (parsedValue.toInt() != 1)
LOG_AND_DELETE("ParsedCookie version %d not supported (only support version=1)", parsedValue.toInt());
} else
LOG_AND_DELETE("Invalid cookie %s (version)", cookie.ascii().data());
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_AND_DELETE("Invalid cookie %s (secure)", cookie.ascii().data());
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_AND_DELETE("Invalid cookie %s (HttpOnly)", cookie.ascii().data());
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());
}
}
}
// Check if the cookie is valid with respect to the size limit.
if (!res->isUnderSizeLimit())
LOG_AND_DELETE("ParsedCookie %s is above the 4kb in length : REJECTED", cookie.ascii().data());
// 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->setDefaultDomain(m_defaultCookieURL);
// According to the Cookie Specificaiton (RFC6265, section 4.1.2.4 and 5.2.4, http://tools.ietf.org/html/rfc6265),
// If no path was provided or the first character of the path value is not '/', set it to the host's path
//
// REFERENCE
// 4.1.2.4. The Path Attribute
//
// The scope of each cookie is limited to a set of paths, controlled by
// the Path attribute. If the server omits the Path attribute, the user
// agent will use the "directory" of the request-uri's path component as
// the default value. (See Section 5.1.4 for more details.)
// ...........
// 5.2.4. The Path Attribute
//
// If the attribute-name case-insensitively matches the string "Path",
// the user agent MUST process the cookie-av as follows.
//
// If the attribute-value is empty or if the first character of the
// attribute-value is not %x2F ("/"):
//
// Let cookie-path be the default-path.
//
// Otherwise:
//
// Let cookie-path be the attribute-value.
//
// Append an attribute to the cookie-attribute-list with an attribute-
// name of Path and an attribute-value of cookie-path.
if (!res->path() || !res->path().length() || !res->path().startsWith("/", false)) {
String path = m_defaultCookieURL.string().substring(m_defaultCookieURL.pathStart(), m_defaultCookieURL.pathAfterLastSlash() - m_defaultCookieURL.pathStart() - 1);
if (path.isEmpty())
path = "/";
// Since this is reading the raw url string, it could contain percent-encoded sequences. We
// want it to be comparable to the return value of url.path(), which is not percent-encoded,
// so we must remove the escape sequences.
res->setPath(decodeURLEscapeSequences(path));
}
return res;
}
示例2: 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 ParsedCookie : %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("ParsedCookie 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("ParsedCookie %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;
}