本文整理汇总了C++中ParsedCookie::domain方法的典型用法代码示例。如果您正苦于以下问题:C++ ParsedCookie::domain方法的具体用法?C++ ParsedCookie::domain怎么用?C++ ParsedCookie::domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedCookie
的用法示例。
在下文中一共展示了ParsedCookie::domain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateHtmlFragmentForCookies
String CookieManager::generateHtmlFragmentForCookies()
{
CookieLog("CookieManager - generateHtmlFragmentForCookies\n");
Vector<ParsedCookie*> cookieCandidates;
for (HashMap<String, CookieMap*>::iterator it = m_managerMap.begin(); it != m_managerMap.end(); ++it)
it->second->getAllChildCookies(&cookieCandidates);
String result;
ParsedCookie* cookie = 0;
result.append(String("<table style=\"word-wrap:break-word\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\"><tr><th>Domain</th><th>Path</th><th>Protocol</th><th>Name</th><th>Value</th><th>Secure</th><th>HttpOnly</th><th>Session</th></tr>"));
for (size_t i = 0; i < cookieCandidates.size(); ++i) {
cookie = cookieCandidates[i];
result.append(String("<tr><td align=\"center\">"));
result.append(cookie->domain());
result.append(String("<td align=\"center\">"));
result.append(cookie->path());
result.append(String("<td align=\"center\">"));
result.append(cookie->protocol());
result.append(String("<td align=\"center\">"));
result.append(cookie->name());
result.append(String("<td align=\"center\" style= \"word-break:break-all\">"));
result.append(cookie->value());
result.append(String("<td align=\"center\">"));
result.append(String(cookie->isSecure() ? "Yes" : "No"));
result.append(String("<td align=\"center\">"));
result.append(String(cookie->isHttpOnly() ? "Yes" : "No"));
result.append(String("<td align=\"center\">"));
result.append(String(cookie->isSession() ? "Yes" : "No"));
result.append(String("</td></tr>"));
}
result.append(String("</table>"));
return result;
}
示例2: getBackingStoreCookies
void CookieManager::getBackingStoreCookies()
{
Vector<ParsedCookie*> cookies = cookieBackingStore().getAllCookies();
for (size_t i = 0; i < cookies.size(); ++i) {
ParsedCookie* newCookie = cookies[i];
if (newCookie->hasExpired()) {
cookieBackingStore().remove(newCookie);
delete newCookie;
} else {
CookieMap* curMap = m_managerMap.get(newCookie->domain());
if (!curMap) {
curMap = new CookieMap();
m_managerMap.add(newCookie->domain(), curMap);
}
// Use the straightforward add
curMap->add(newCookie);
m_count++;
}
}
}
示例3: parseOneCookie
//.........这里部分代码省略.........
parsedValue = cookie.substring(tokenStart, tokenEnd - tokenStart);
} else {
// If the parsedValue is empty, initialise it in case we need it
parsedValue = String();
// Handle a token without value.
length = pairEnd - tokenStart;
}
// Detect which "cookie-av" is parsed
// Look at the first char then parse the whole for performance issue
switch (cookie[tokenStartSvg]) {
case 'P':
case 'p' : {
if (length >= 4 && cookie.find("ath", tokenStartSvg + 1, false)) {
// We need the path to be decoded to match those returned from KURL::path().
// The path attribute may or may not include percent-encoded characters. Fortunately
// if there are no percent-encoded characters, decoding the url is a no-op.
res->setPath(decodeURLEscapeSequences(parsedValue));
} else
LOG_AND_DELETE("Invalid cookie %s (path)", cookie.ascii().data());
break;
}
case 'D':
case 'd' : {
if (length >= 6 && cookie.find("omain", tokenStartSvg + 1, false)) {
if (parsedValue.length() > 1 && parsedValue[0] == '"' && parsedValue[parsedValue.length() - 1] == '"')
parsedValue = parsedValue.substring(1, parsedValue.length() - 2);
// If the domain does not start with a dot, add one for security checks,
// For example: ab.c.com dose not domain match b.c.com;
String realDomain = parsedValue[0] == '.' ? parsedValue : "." + parsedValue;
res->setDomain(realDomain);
} else
LOG_AND_DELETE("Invalid cookie %s (domain)", cookie.ascii().data());
break;
}
case 'E' :
case 'e' : {
if (length >= 7 && cookie.find("xpires", tokenStartSvg + 1, false))
res->setExpiry(parsedValue);
else
LOG_AND_DELETE("Invalid cookie %s (expires)", cookie.ascii().data());
break;
}
case 'M' :
case 'm' : {
if (length >= 7 && cookie.find("ax-age", tokenStartSvg + 1, false))
res->setMaxAge(parsedValue);
else
LOG_AND_DELETE("Invalid cookie %s (max-age)", cookie.ascii().data());
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_AND_DELETE("Invalid cookie %s (comment)", cookie.ascii().data());
break;
}
case 'V' :
示例4: invokeSendChangesToDatabase
void CookieDatabaseBackingStore::invokeSendChangesToDatabase()
{
ASSERT(isCurrentThread());
if (!m_db.isOpen()) {
LOG_ERROR("Timer Fired, but database is closed.");
return;
}
Vector<CookieAction> changedCookies;
{
MutexLocker lock(m_mutex);
changedCookies.swap(m_changedCookies);
ASSERT(m_changedCookies.isEmpty());
}
if (changedCookies.isEmpty()) {
CookieLog("CookieBackingStore - Timer fired, but no cookies in changelist");
return;
}
CookieLog("CookieBackingStore - Timer fired, sending changes to database. We have %d changes", changedCookies.size());
SQLiteTransaction transaction(m_db, false);
transaction.begin();
// Iterate through every element in the change list to make calls
// If error occurs, ignore it and continue to the next statement
size_t sizeOfChange = changedCookies.size();
for (size_t i = 0; i < sizeOfChange; i++) {
SQLiteStatement* m_statement;
const ParsedCookie cookie = changedCookies[i].first;
UpdateParameter action = changedCookies[i].second;
if (action == Delete) {
m_statement = m_deleteStatement;
CookieLog("CookieBackingStore - deleting cookie %s.", cookie.toString().utf8().data());
// Binds all the values
if (m_statement->bindText(1, cookie.name()) || m_statement->bindText(2, cookie.domain())
|| m_statement->bindText(3, cookie.path()) || m_statement->bindText(4, cookie.protocol())) {
LOG_ERROR("Cannot bind cookie data to delete");
LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg());
ASSERT_NOT_REACHED();
continue;
}
} else {
if (action == Update) {
CookieLog("CookieBackingStore - updating cookie %s.", cookie.toString().utf8().data());
m_statement = m_updateStatement;
} else {
CookieLog("CookieBackingStore - inserting cookie %s.", cookie.toString().utf8().data());
m_statement = m_insertStatement;
}
// Binds all the values
if (m_statement->bindText(1, cookie.name()) || m_statement->bindText(2, cookie.value())
|| m_statement->bindText(3, cookie.domain()) || m_statement->bindText(4, cookie.path())
|| m_statement->bindDouble(5, cookie.expiry()) || m_statement->bindDouble(6, cookie.lastAccessed())
|| m_statement->bindInt64(7, cookie.isSecure()) || m_statement->bindInt64(8, cookie.isHttpOnly())
|| m_statement->bindDouble(9, cookie.creationTime()) || m_statement->bindText(10, cookie.protocol())) {
LOG_ERROR("Cannot bind cookie data to save");
LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg());
ASSERT_NOT_REACHED();
continue;
}
}
int rc = m_statement->step();
m_statement->reset();
if (rc != SQLResultOk && rc != SQLResultDone) {
LOG_ERROR("Cannot make call to the database");
LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg());
ASSERT_NOT_REACHED();
continue;
}
}
transaction.commit();
CookieLog("CookieBackingStore - transaction complete");
}
示例5: parseOneCookie
//.........这里部分代码省略.........
while (tokenEnd > tokenStart && isLightweightSpace(cookie[tokenEnd]))
tokenEnd--;
parsedValue = cookie.substring(tokenStart, tokenEnd - tokenStart);
} else {
// If the parsedValue is empty, initialise it in case we need it
parsedValue = String();
// Handle a token without value.
length = pairEnd - tokenStart;
}
// Detect which "cookie-av" is parsed
// Look at the first char then parse the whole for performance issue
switch (cookie[tokenStartSvg]) {
case 'P':
case 'p' : {
if (length >= 4 && cookie.find("ath", tokenStartSvg + 1, false))
res->setPath(parsedValue);
else {
LOG_ERROR("Invalid cookie %s (path)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'D':
case 'd' : {
if (length >= 6 && cookie.find("omain", tokenStartSvg + 1, false)) {
// If the domain does not start with a dot, add one for security checks
String realDomain = parsedValue[0] == '.' ? parsedValue : "." + parsedValue;
res->setDomain(realDomain);
} else {
LOG_ERROR("Invalid cookie %s (domain)", cookie.ascii().data());
delete res;
return 0;
}
break;
}
case 'E' :
case 'e' : {
if (length >= 7 && cookie.find("xpires", tokenStartSvg + 1, false))
res->setExpiry(parsedValue);
else {
LOG_ERROR("Invalid cookie %s (expires)", cookie.ascii().data());
delete res;
return 0;
}
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' : {