import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Http
|
||||
* @subpackage CookieJar
|
||||
* @version $Id: CookieJar.php 9098 2008-03-30 19:29:10Z thomas $
|
||||
* @version $Id: CookieJar.php 13641 2009-01-14 21:58:25Z doctorrock83 $
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com/)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -48,7 +48,7 @@ require_once "Zend/Http/Response.php";
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com/)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Http_CookieJar
|
||||
class Zend_Http_CookieJar implements Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Return cookie(s) as a Zend_Http_Cookie object
|
||||
@ -87,6 +87,13 @@ class Zend_Http_CookieJar
|
||||
*/
|
||||
protected $cookies = array();
|
||||
|
||||
/**
|
||||
* The Zend_Http_Cookie array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_rawCookies = array();
|
||||
|
||||
/**
|
||||
* Construct a new CookieJar object
|
||||
*
|
||||
@ -113,6 +120,7 @@ class Zend_Http_CookieJar
|
||||
if (! isset($this->cookies[$domain])) $this->cookies[$domain] = array();
|
||||
if (! isset($this->cookies[$domain][$path])) $this->cookies[$domain][$path] = array();
|
||||
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
|
||||
$this->_rawCookies[] = $cookie;
|
||||
} else {
|
||||
require_once 'Zend/Http/Exception.php';
|
||||
throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object');
|
||||
@ -347,4 +355,45 @@ class Zend_Http_CookieJar
|
||||
$jar->addCookiesFromResponse($response, $ref_uri);
|
||||
return $jar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by Countable interface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_rawCookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by IteratorAggregate interface
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->_rawCookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the jar is empty of any cookie
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return count($this) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empties the cookieJar of any cookie
|
||||
*
|
||||
* @return Zend_Http_CookieJar
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->cookies = $this->_rawCookies = array();
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user