forked from espressif/arduino-esp32
* Check for cookieJar before setting cookies * Return as soon as possible w/o _cookieJar
This commit is contained in:
@ -1543,6 +1543,10 @@ void HTTPClient::clearAllCookies()
|
|||||||
|
|
||||||
void HTTPClient::setCookie(String date, String headerValue)
|
void HTTPClient::setCookie(String date, String headerValue)
|
||||||
{
|
{
|
||||||
|
if (!_cookieJar)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
#define HTTP_TIME_PATTERN "%a, %d %b %Y %H:%M:%S"
|
#define HTTP_TIME_PATTERN "%a, %d %b %Y %H:%M:%S"
|
||||||
|
|
||||||
Cookie cookie;
|
Cookie cookie;
|
||||||
@ -1670,6 +1674,10 @@ bool HTTPClient::generateCookieString(String *cookieString)
|
|||||||
*cookieString = "";
|
*cookieString = "";
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
if (!_cookieJar)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (auto c = _cookieJar->begin(); c != _cookieJar->end(); ++c) {
|
for (auto c = _cookieJar->begin(); c != _cookieJar->end(); ++c) {
|
||||||
if ((c->max_age.valid && ((c->date + c->max_age.duration) < now_gmt)) || (!c->max_age.valid && c->expires.valid && c->expires.date < now_gmt)) {
|
if ((c->max_age.valid && ((c->date + c->max_age.duration) < now_gmt)) || (!c->max_age.valid && c->expires.valid && c->expires.date < now_gmt)) {
|
||||||
_cookieJar->erase(c);
|
_cookieJar->erase(c);
|
||||||
@ -1682,5 +1690,6 @@ bool HTTPClient::generateCookieString(String *cookieString)
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user