|
|
@@ -78,6 +78,13 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
const COOKIE_STRING_CONCAT = 2;
|
|
|
|
|
|
/**
|
|
|
+ * Return all cookies as one long string (strict mode)
|
|
|
+ * - Single space after the semi-colon separating each cookie
|
|
|
+ * - Remove trailing semi-colon, if any
|
|
|
+ */
|
|
|
+ const COOKIE_STRING_CONCAT_STRICT = 3;
|
|
|
+
|
|
|
+ /**
|
|
|
* Array storing cookies
|
|
|
*
|
|
|
* Cookies are stored according to domain and path:
|
|
|
@@ -173,6 +180,9 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
public function getAllCookies($ret_as = self::COOKIE_OBJECT)
|
|
|
{
|
|
|
$cookies = $this->_flattenCookiesArray($this->cookies, $ret_as);
|
|
|
+ if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
|
|
|
+ $cookies = rtrim(trim($cookies), ';');
|
|
|
+ }
|
|
|
return $cookies;
|
|
|
}
|
|
|
|
|
|
@@ -209,6 +219,9 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
|
|
|
// Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
|
|
|
$ret = $this->_flattenCookiesArray($ret, $ret_as);
|
|
|
+ if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
|
|
|
+ $ret = rtrim(trim($ret), ';');
|
|
|
+ }
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
|
@@ -245,6 +258,10 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
return $cookie;
|
|
|
break;
|
|
|
|
|
|
+ case self::COOKIE_STRING_CONCAT_STRICT:
|
|
|
+ return rtrim(trim($cookie->__toString()), ';');
|
|
|
+ break;
|
|
|
+
|
|
|
case self::COOKIE_STRING_ARRAY:
|
|
|
case self::COOKIE_STRING_CONCAT:
|
|
|
return $cookie->__toString();
|
|
|
@@ -270,9 +287,12 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
*/
|
|
|
protected function _flattenCookiesArray($ptr, $ret_as = self::COOKIE_OBJECT) {
|
|
|
if (is_array($ptr)) {
|
|
|
- $ret = ($ret_as == self::COOKIE_STRING_CONCAT ? '' : array());
|
|
|
+ $ret = ($ret_as == self::COOKIE_STRING_CONCAT || $ret_as == self::COOKIE_STRING_CONCAT_STRICT) ? '' : array();
|
|
|
foreach ($ptr as $item) {
|
|
|
- if ($ret_as == self::COOKIE_STRING_CONCAT) {
|
|
|
+ if ($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
|
|
|
+ $postfix_combine = (!is_array($item) ? ' ' : '');
|
|
|
+ $ret .= $this->_flattenCookiesArray($item, $ret_as) . $postfix_combine;
|
|
|
+ } elseif ($ret_as == self::COOKIE_STRING_CONCAT) {
|
|
|
$ret .= $this->_flattenCookiesArray($item, $ret_as);
|
|
|
} else {
|
|
|
$ret = array_merge($ret, $this->_flattenCookiesArray($item, $ret_as));
|
|
|
@@ -285,6 +305,9 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
|
|
return array($ptr->__toString());
|
|
|
break;
|
|
|
|
|
|
+ case self::COOKIE_STRING_CONCAT_STRICT:
|
|
|
+ // break intentionally omitted
|
|
|
+
|
|
|
case self::COOKIE_STRING_CONCAT:
|
|
|
return $ptr->__toString();
|
|
|
break;
|