diff --git a/headers/os/net/NetworkCookieJar.h b/headers/os/net/NetworkCookieJar.h index 0bf070f30f..58364a6a97 100644 --- a/headers/os/net/NetworkCookieJar.h +++ b/headers/os/net/NetworkCookieJar.h @@ -58,10 +58,13 @@ public: virtual status_t Unflatten(type_code code, const void* buffer, ssize_t size); + BNetworkCookieJar& operator=(const BNetworkCookieJar& other); + // Iterators Iterator GetIterator() const; UrlIterator GetUrlIterator(const BUrl& url) const; + private: void _DoFlatten() const; diff --git a/src/kits/network/libnetapi/NetworkCookieJar.cpp b/src/kits/network/libnetapi/NetworkCookieJar.cpp index 03c894cc1b..ee0c4de437 100644 --- a/src/kits/network/libnetapi/NetworkCookieJar.cpp +++ b/src/kits/network/libnetapi/NetworkCookieJar.cpp @@ -71,6 +71,8 @@ BNetworkCookieJar::~BNetworkCookieJar() { for (Iterator it = GetIterator(); it.Next() != NULL;) delete it.Remove(); + + delete fCookieHashMap; } @@ -356,6 +358,30 @@ BNetworkCookieJar::Unflatten(type_code, const void* buffer, ssize_t size) } +BNetworkCookieJar& +BNetworkCookieJar::operator=(const BNetworkCookieJar& other) +{ + if(&other == this) + return *this; + + BArchivable::operator=(other); + BFlattenable::operator=(other); + + fFlattened = other.fFlattened; + + delete fCookieHashMap; + fCookieHashMap = new PrivateHashMap(); + + for (Iterator it = other.GetIterator(); it.HasNext();) + { + BNetworkCookie* cookie = it.Next(); + AddCookie(*cookie); // Pass by reference so the cookie is copied. + } + + return *this; +} + + // #pragma mark Iterators