Simplify cookie string-ification code.
This commit is contained in:
@@ -39,7 +39,7 @@ BNetworkCookie::BNetworkCookie(const char* name, const char* value,
|
||||
|
||||
SetDomain(url.Host());
|
||||
|
||||
if(url.Protocol() == "file" && url.Host().Length() == 0)
|
||||
if (url.Protocol() == "file" && url.Host().Length() == 0)
|
||||
{
|
||||
SetDomain("localhost");
|
||||
// make sure cookies set from a file:// URL are stored somewhere.
|
||||
@@ -100,7 +100,7 @@ BNetworkCookie::ParseCookieString(const BString& string, const BUrl& url)
|
||||
SetPath(_DefaultPathForUrl(url));
|
||||
SetDomain(url.Host());
|
||||
fHostOnly = true;
|
||||
if(url.Protocol() == "file" && url.Host().Length() == 0)
|
||||
if (url.Protocol() == "file" && url.Host().Length() == 0)
|
||||
{
|
||||
fDomain = "localhost";
|
||||
// make sure cookies set from a file:// URL are stored somewhere.
|
||||
@@ -378,11 +378,19 @@ BNetworkCookie::HttpOnly() const
|
||||
const BString&
|
||||
BNetworkCookie::RawCookie(bool full) const
|
||||
{
|
||||
if (full && !fRawFullCookieValid) {
|
||||
fRawFullCookie.Truncate(0);
|
||||
fRawFullCookieValid = true;
|
||||
if (!fRawCookieValid) {
|
||||
fRawCookie.Truncate(0);
|
||||
fRawCookieValid = true;
|
||||
|
||||
fRawFullCookie << fName << "=" << fValue;
|
||||
fRawCookie << fName << "=" << fValue;
|
||||
}
|
||||
|
||||
if (!full)
|
||||
return fRawCookie;
|
||||
|
||||
if (!fRawFullCookieValid) {
|
||||
fRawFullCookie = fRawCookie;
|
||||
fRawFullCookieValid = true;
|
||||
|
||||
if (HasDomain())
|
||||
fRawFullCookie << "; Domain=" << fDomain;
|
||||
@@ -395,14 +403,9 @@ BNetworkCookie::RawCookie(bool full) const
|
||||
if (HttpOnly())
|
||||
fRawFullCookie << "; HttpOnly";
|
||||
|
||||
} else if (!full && !fRawCookieValid) {
|
||||
fRawCookie.Truncate(0);
|
||||
fRawCookieValid = true;
|
||||
|
||||
fRawCookie << fName << "=" << fValue;
|
||||
}
|
||||
|
||||
return full ? fRawFullCookie : fRawCookie;
|
||||
return fRawFullCookie;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user