mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 00:07:59 +02:00
Added support for a 'Priority' attribute on cookies.
This commit is contained in:
@@ -102,6 +102,10 @@ HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
|
||||
{
|
||||
setPath(value);
|
||||
}
|
||||
else if (icompare(name, "Priority") == 0)
|
||||
{
|
||||
setPriority(value);
|
||||
}
|
||||
else if (icompare(name, "max-age") == 0)
|
||||
{
|
||||
setMaxAge(NumberParser::parse(value));
|
||||
@@ -115,7 +119,7 @@ HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
|
||||
int tzd;
|
||||
DateTime exp = DateTimeParser::parse(value, tzd);
|
||||
Timestamp now;
|
||||
setMaxAge((int) ((exp.timestamp() - now) / Timestamp::resolution()));
|
||||
setMaxAge((int) ((exp.timestamp() - now)/Timestamp::resolution()));
|
||||
}
|
||||
else if (icompare(name, "version") == 0)
|
||||
{
|
||||
@@ -152,6 +156,7 @@ HTTPCookie::HTTPCookie(const HTTPCookie& cookie):
|
||||
_comment(cookie._comment),
|
||||
_domain(cookie._domain),
|
||||
_path(cookie._path),
|
||||
_priority(cookie._priority),
|
||||
_secure(cookie._secure),
|
||||
_maxAge(cookie._maxAge),
|
||||
_httpOnly(cookie._httpOnly)
|
||||
@@ -174,6 +179,7 @@ HTTPCookie& HTTPCookie::operator = (const HTTPCookie& cookie)
|
||||
_comment = cookie._comment;
|
||||
_domain = cookie._domain;
|
||||
_path = cookie._path;
|
||||
_priority = cookie._priority;
|
||||
_secure = cookie._secure;
|
||||
_maxAge = cookie._maxAge;
|
||||
_httpOnly = cookie._httpOnly;
|
||||
@@ -217,6 +223,11 @@ void HTTPCookie::setPath(const std::string& path)
|
||||
_path = path;
|
||||
}
|
||||
|
||||
void HTTPCookie::setPriority(const std::string& priority)
|
||||
{
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
|
||||
void HTTPCookie::setSecure(bool secure)
|
||||
{
|
||||
@@ -256,10 +267,15 @@ std::string HTTPCookie::toString() const
|
||||
result.append("; path=");
|
||||
result.append(_path);
|
||||
}
|
||||
if (!_priority.empty())
|
||||
{
|
||||
result.append("; Priority=");
|
||||
result.append(_priority);
|
||||
}
|
||||
if (_maxAge != -1)
|
||||
{
|
||||
Timestamp ts;
|
||||
ts += _maxAge * Timestamp::resolution();
|
||||
ts += _maxAge*Timestamp::resolution();
|
||||
result.append("; expires=");
|
||||
DateTimeFormatter::append(result, ts, DateTimeFormat::HTTP_FORMAT);
|
||||
}
|
||||
@@ -296,6 +312,13 @@ std::string HTTPCookie::toString() const
|
||||
result.append(_path);
|
||||
result.append("\"");
|
||||
}
|
||||
if (!_priority.empty())
|
||||
{
|
||||
result.append("; Priority=\"");
|
||||
result.append(_priority);
|
||||
result.append("\"");
|
||||
}
|
||||
|
||||
if (_maxAge != -1)
|
||||
{
|
||||
result.append("; Max-Age=\"");
|
||||
|
Reference in New Issue
Block a user