1- #include " CookieJar .h"
1+ #include " AsyncCookieJar .h"
22#include < cctype>
33#include < cstring>
44#include " AsyncHttpClient.h"
@@ -17,31 +17,31 @@ static uint8_t countDomainDots(const String& domain) {
1717 return dots;
1818}
1919
20- CookieJar::CookieJar (AsyncHttpClient* client) : _client(client) {}
20+ AsyncCookieJar::AsyncCookieJar (AsyncHttpClient* client) : _client(client) {}
2121
22- void CookieJar ::lock () const {
22+ void AsyncCookieJar ::lock () const {
2323 if (_client)
2424 _client->lock ();
2525}
2626
27- void CookieJar ::unlock () const {
27+ void AsyncCookieJar ::unlock () const {
2828 if (_client)
2929 _client->unlock ();
3030}
3131
32- void CookieJar ::clearCookies () {
32+ void AsyncCookieJar ::clearCookies () {
3333 lock ();
3434 _cookies.clear ();
3535 unlock ();
3636}
3737
38- void CookieJar ::setAllowCookieDomainAttribute (bool enable) {
38+ void AsyncCookieJar ::setAllowCookieDomainAttribute (bool enable) {
3939 lock ();
4040 _allowCookieDomainAttribute = enable;
4141 unlock ();
4242}
4343
44- void CookieJar ::addAllowedCookieDomain (const char * domain) {
44+ void AsyncCookieJar ::addAllowedCookieDomain (const char * domain) {
4545 if (!domain || strlen (domain) == 0 )
4646 return ;
4747 String normalized = normalizeDomainForStorage (String (domain));
@@ -60,13 +60,13 @@ void CookieJar::addAllowedCookieDomain(const char* domain) {
6060 unlock ();
6161}
6262
63- void CookieJar ::clearAllowedCookieDomains () {
63+ void AsyncCookieJar ::clearAllowedCookieDomains () {
6464 lock ();
6565 _allowedCookieDomains.clear ();
6666 unlock ();
6767}
6868
69- void CookieJar ::setCookie (const char * name, const char * value, const char * path, const char * domain, bool secure) {
69+ void AsyncCookieJar ::setCookie (const char * name, const char * value, const char * path, const char * domain, bool secure) {
7070 if (!name || strlen (name) == 0 )
7171 return ;
7272 if (!isValidHttpHeaderValue (String (name)))
@@ -108,7 +108,7 @@ void CookieJar::setCookie(const char* name, const char* value, const char* path,
108108 unlock ();
109109}
110110
111- bool CookieJar ::isIpLiteral (const String& host) const {
111+ bool AsyncCookieJar ::isIpLiteral (const String& host) const {
112112 if (host.length () == 0 )
113113 return false ;
114114 bool hasColon = false ;
@@ -131,7 +131,7 @@ bool CookieJar::isIpLiteral(const String& host) const {
131131 return hasColon || hasDot;
132132}
133133
134- bool CookieJar ::normalizeCookieDomain (String& domain, const String& host, bool domainAttributeProvided,
134+ bool AsyncCookieJar ::normalizeCookieDomain (String& domain, const String& host, bool domainAttributeProvided,
135135 bool * outHostOnly) const {
136136 if (outHostOnly)
137137 *outHostOnly = true ;
@@ -186,7 +186,7 @@ bool CookieJar::normalizeCookieDomain(String& domain, const String& host, bool d
186186 return true ;
187187}
188188
189- bool CookieJar ::domainMatches (const String& cookieDomain, const String& host) const {
189+ bool AsyncCookieJar ::domainMatches (const String& cookieDomain, const String& host) const {
190190 if (cookieDomain.length () == 0 )
191191 return true ;
192192 if (host.equalsIgnoreCase (cookieDomain))
@@ -199,7 +199,7 @@ bool CookieJar::domainMatches(const String& cookieDomain, const String& host) co
199199 return host.substring (offset).equalsIgnoreCase (cookieDomain);
200200}
201201
202- bool CookieJar ::pathMatches (const String& cookiePath, const String& requestPath) const {
202+ bool AsyncCookieJar ::pathMatches (const String& cookiePath, const String& requestPath) const {
203203 String req = requestPath;
204204 int q = req.indexOf (' ?' );
205205 if (q != -1 )
@@ -218,7 +218,7 @@ bool CookieJar::pathMatches(const String& cookiePath, const String& requestPath)
218218 return req.length () > cpath.length () && req.charAt (cpath.length ()) == ' /' ;
219219}
220220
221- bool CookieJar ::cookieMatchesRequest (const StoredCookie& cookie, const AsyncHttpRequest* request,
221+ bool AsyncCookieJar ::cookieMatchesRequest (const StoredCookie& cookie, const AsyncHttpRequest* request,
222222 int64_t nowSeconds) const {
223223 if (!request)
224224 return false ;
@@ -238,11 +238,11 @@ bool CookieJar::cookieMatchesRequest(const StoredCookie& cookie, const AsyncHttp
238238 return !cookie.value .isEmpty ();
239239}
240240
241- bool CookieJar ::isCookieExpired (const StoredCookie& cookie, int64_t nowSeconds) const {
241+ bool AsyncCookieJar ::isCookieExpired (const StoredCookie& cookie, int64_t nowSeconds) const {
242242 return cookie.expiresAt != -1 && nowSeconds >= cookie.expiresAt ;
243243}
244244
245- void CookieJar ::purgeExpiredCookies (int64_t nowSeconds) {
245+ void AsyncCookieJar ::purgeExpiredCookies (int64_t nowSeconds) {
246246 for (auto it = _cookies.begin (); it != _cookies.end ();) {
247247 if (isCookieExpired (*it, nowSeconds)) {
248248 it = _cookies.erase (it);
@@ -252,7 +252,7 @@ void CookieJar::purgeExpiredCookies(int64_t nowSeconds) {
252252 }
253253}
254254
255- void CookieJar ::evictOneCookieLocked () {
255+ void AsyncCookieJar ::evictOneCookieLocked () {
256256 if (_cookies.empty ())
257257 return ;
258258 size_t bestIndex = 0 ;
@@ -303,7 +303,7 @@ void CookieJar::evictOneCookieLocked() {
303303 _cookies.erase (_cookies.begin () + static_cast <std::vector<StoredCookie>::difference_type>(bestIndex));
304304}
305305
306- void CookieJar ::applyCookies (AsyncHttpRequest* request) {
306+ void AsyncCookieJar ::applyCookies (AsyncHttpRequest* request) {
307307 if (!request)
308308 return ;
309309 int64_t now = currentTimeSeconds ();
@@ -343,7 +343,7 @@ void CookieJar::applyCookies(AsyncHttpRequest* request) {
343343 }
344344}
345345
346- void CookieJar ::storeResponseCookie (const AsyncHttpRequest* request, const String& setCookieValue) {
346+ void AsyncCookieJar ::storeResponseCookie (const AsyncHttpRequest* request, const String& setCookieValue) {
347347 if (!request)
348348 return ;
349349 String raw = setCookieValue;
0 commit comments