Skip to content

Commit 96f3dc0

Browse files
committed
correction cookiejar conflict
1 parent aa23647 commit 96f3dc0

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/AsyncHttpClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <memory>
1111
#include <utility>
1212
#include "ConnectionPool.h"
13-
#include "CookieJar.h"
13+
#include "AsyncCookieJar.h"
1414
#include "HttpHelpers.h"
1515
#include "RedirectHandler.h"
1616

@@ -24,7 +24,7 @@ AsyncHttpClient::AsyncHttpClient()
2424
: _defaultTimeout(10000), _defaultUserAgent(String("ESPAsyncWebClient/") + ESP_ASYNC_WEB_CLIENT_VERSION),
2525
_bodyChunkCallback(nullptr), _maxBodySize(kDefaultMaxBodyBytes), _followRedirects(false), _maxRedirectHops(3),
2626
_maxHeaderBytes(kDefaultMaxHeaderBytes) {
27-
_cookieJar.reset(new CookieJar(this));
27+
_cookieJar.reset(new AsyncCookieJar(this));
2828
_connectionPool.reset(new ConnectionPool(this));
2929
_redirectHandler.reset(new RedirectHandler(this));
3030
#if defined(ARDUINO_ARCH_ESP32) && defined(ASYNC_HTTP_ENABLE_AUTOLOOP)

src/AsyncHttpClient.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <freertos/semphr.h>
2626
#endif
2727

28-
class CookieJar;
28+
class AsyncCookieJar;
2929
class ConnectionPool;
3030
class RedirectHandler;
3131

@@ -111,7 +111,7 @@ class AsyncHttpClient {
111111
void loop(); // manual timeout / queue progression
112112

113113
private:
114-
friend class CookieJar;
114+
friend class AsyncCookieJar;
115115
friend class ConnectionPool;
116116
friend class RedirectHandler;
117117

@@ -200,7 +200,7 @@ class AsyncHttpClient {
200200
AsyncHttpTLSConfig _defaultTlsConfig;
201201
bool _keepAliveEnabled = false;
202202
uint32_t _keepAliveIdleMs = 5000;
203-
std::unique_ptr<CookieJar> _cookieJar;
203+
std::unique_ptr<AsyncCookieJar> _cookieJar;
204204
std::unique_ptr<ConnectionPool> _connectionPool;
205205
std::unique_ptr<RedirectHandler> _redirectHandler;
206206

src/CookieJar.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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;

src/CookieJar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
class AsyncHttpClient;
99

10-
class CookieJar {
10+
class AsyncCookieJar {
1111
public:
12-
explicit CookieJar(AsyncHttpClient* client);
12+
explicit AsyncCookieJar(AsyncHttpClient* client);
1313

1414
void clearCookies();
1515
void setAllowCookieDomainAttribute(bool enable);

test/test_cookies/test_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define private public
55
#include "AsyncHttpClient.h"
6-
#include "CookieJar.h"
6+
#include "AsyncCookieJar.h"
77
#undef private
88

99
static void test_domain_matching_subdomains() {

test/test_redirects/test_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#define private public
66
#include "AsyncHttpClient.h"
7-
#include "CookieJar.h"
7+
#include "AsyncCookieJar.h"
88
#include "RedirectHandler.h"
99
#undef private
1010

0 commit comments

Comments
 (0)