1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00

Porting a recent cookie fix to remove empty cookies when they are set

This commit is contained in:
Michael Dowling 2014-02-05 23:58:26 -08:00
parent 0994a9e138
commit 217db1dcbf

View File

@ -113,6 +113,7 @@ class ArrayCookieJar implements CookieJarInterface, \Serializable
if ($this->strictMode) {
throw new \RuntimeException('Invalid cookie: ' . $result);
} else {
$this->removeCookieIfEmpty($cookie);
return false;
}
}
@ -229,4 +230,18 @@ class ArrayCookieJar implements CookieJarInterface, \Serializable
return $cookies;
}
/**
* If a cookie already exists and the server asks to set it again with a null value, the
* cookie must be deleted.
*
* @param SetCookie $cookie
*/
private function removeCookieIfEmpty(SetCookie $cookie)
{
$cookieValue = $cookie->getValue();
if ($cookieValue === null || $cookieValue === '') {
$this->remove($cookie->getDomain(), $cookie->getPath(), $cookie->getName());
}
}
}