summaryrefslogtreecommitdiff
path: root/framework/Web/THttpRequest.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r--framework/Web/THttpRequest.php452
1 files changed, 1 insertions, 451 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 5d77ba60..72e7cdea 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -953,454 +953,4 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
{
$this->remove($offset);
}
-}
-
-/**
- * THttpCookieCollection class.
- *
- * THttpCookieCollection implements a collection class to store cookies.
- * Besides using all functionalities from {@link TList}, you can also
- * retrieve a cookie by its name using either {@link findCookieByName} or
- * simply:
- * <code>
- * $cookie=$collection[$cookieName];
- * </code>
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @package System.Web
- * @since 3.0
- */
-class THttpCookieCollection extends TList
-{
- /**
- * @var mixed owner of this collection
- */
- private $_o;
-
- /**
- * Constructor.
- * @param mixed owner of this collection.
- */
- public function __construct($owner=null)
- {
- $this->_o=$owner;
- }
-
- /**
- * Inserts an item at the specified position.
- * This overrides the parent implementation by performing additional
- * operations for each newly added THttpCookie object.
- * @param integer the specified position.
- * @param mixed new item
- * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object.
- */
- public function insertAt($index,$item)
- {
- if($item instanceof THttpCookie)
- {
- parent::insertAt($index,$item);
- if($this->_o instanceof THttpResponse)
- $this->_o->addCookie($item);
- }
- else
- throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required');
- }
-
- /**
- * Removes an item at the specified position.
- * This overrides the parent implementation by performing additional
- * cleanup work when removing a TCookie object.
- * @param integer the index of the item to be removed.
- * @return mixed the removed item.
- */
- public function removeAt($index)
- {
- $item=parent::removeAt($index);
- if($this->_o instanceof THttpResponse)
- $this->_o->removeCookie($item);
- return $item;
- }
-
- /**
- * @param integer|string index of the cookie in the collection or the cookie's name
- * @return THttpCookie the cookie found
- */
- public function itemAt($index)
- {
- if(is_integer($index))
- return parent::itemAt($index);
- else
- return $this->findCookieByName($index);
- }
-
- /**
- * Finds the cookie with the specified name.
- * @param string the name of the cookie to be looked for
- * @return THttpCookie the cookie, null if not found
- */
- public function findCookieByName($name)
- {
- foreach($this as $cookie)
- if($cookie->getName()===$name)
- return $cookie;
- return null;
- }
-}
-
-/**
- * THttpCookie class.
- *
- * A THttpCookie instance stores a single cookie, including the cookie name, value,
- * domain, path, expire, and secure.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @package System.Web
- * @since 3.0
- */
-class THttpCookie extends TComponent
-{
- /**
- * @var string domain of the cookie
- */
- private $_domain='';
- /**
- * @var string name of the cookie
- */
- private $_name;
- /**
- * @var string value of the cookie
- */
- private $_value='';
- /**
- * @var integer expire of the cookie
- */
- private $_expire=0;
- /**
- * @var string path of the cookie
- */
- private $_path='/';
- /**
- * @var boolean whether cookie should be sent via secure connection
- */
- private $_secure=false;
- /**
- * @var boolean if true the cookie value will be unavailable to JavaScript
- */
- private $_httpOnly=false;
-
- /**
- * Constructor.
- * @param string name of this cookie
- * @param string value of this cookie
- */
- public function __construct($name,$value)
- {
- $this->_name=$name;
- $this->_value=$value;
- }
-
- /**
- * @return string the domain to associate the cookie with
- */
- public function getDomain()
- {
- return $this->_domain;
- }
-
- /**
- * @param string the domain to associate the cookie with
- */
- public function setDomain($value)
- {
- $this->_domain=$value;
- }
-
- /**
- * @return integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch.
- */
- public function getExpire()
- {
- return $this->_expire;
- }
-
- /**
- * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch.
- */
- public function setExpire($value)
- {
- $this->_expire=TPropertyValue::ensureInteger($value);
- }
-
- /**
- * @return boolean if true the cookie value will be unavailable to JavaScript
- */
- public function getHttpOnly()
- {
- return $this->_httpOnly;
- }
-
- /**
- * @param boolean $value if true the cookie value will be unavailable to JavaScript
- */
- public function setHttpOnly($value)
- {
- $this->_httpOnly = TPropertyValue::ensureBoolean($value);
- }
-
- /**
- * @return string the name of the cookie
- */
- public function getName()
- {
- return $this->_name;
- }
-
- /**
- * @param string the name of the cookie
- */
- public function setName($value)
- {
- $this->_name=$value;
- }
-
- /**
- * @return string the value of the cookie
- */
- public function getValue()
- {
- return $this->_value;
- }
-
- /**
- * @param string the value of the cookie
- */
- public function setValue($value)
- {
- $this->_value=$value;
- }
-
- /**
- * @return string the path on the server in which the cookie will be available on, default is '/'
- */
- public function getPath()
- {
- return $this->_path;
- }
-
- /**
- * @param string the path on the server in which the cookie will be available on
- */
- public function setPath($value)
- {
- $this->_path=$value;
- }
-
- /**
- * @return boolean whether the cookie should only be transmitted over a secure HTTPS connection
- */
- public function getSecure()
- {
- return $this->_secure;
- }
-
- /**
- * @param boolean ether the cookie should only be transmitted over a secure HTTPS connection
- */
- public function setSecure($value)
- {
- $this->_secure=TPropertyValue::ensureBoolean($value);
- }
-}
-
-/**
- * TUri class
- *
- * TUri represents a URI. Given a URI
- * http://joe:whatever@example.com:8080/path/to/script.php?param=value#anchor
- * it will be decomposed as follows,
- * - scheme: http
- * - host: example.com
- * - port: 8080
- * - user: joe
- * - password: whatever
- * - path: /path/to/script.php
- * - query: param=value
- * - fragment: anchor
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @package System.Web
- * @since 3.0
- */
-class TUri extends TComponent
-{
- /**
- * @var array list of default ports for known schemes
- */
- private static $_defaultPort=array(
- 'ftp'=>21,
- 'gopher'=>70,
- 'http'=>80,
- 'https'=>443,
- 'news'=>119,
- 'nntp'=>119,
- 'wais'=>210,
- 'telnet'=>23
- );
- /**
- * @var string scheme of the URI
- */
- private $_scheme;
- /**
- * @var string host name of the URI
- */
- private $_host;
- /**
- * @var integer port of the URI
- */
- private $_port;
- /**
- * @var string user of the URI
- */
- private $_user;
- /**
- * @var string password of the URI
- */
- private $_pass;
- /**
- * @var string path of the URI
- */
- private $_path;
- /**
- * @var string query string of the URI
- */
- private $_query;
- /**
- * @var string fragment of the URI
- */
- private $_fragment;
- /**
- * @var string the URI
- */
- private $_uri;
-
- /**
- * Constructor.
- * Decomposes the specified URI into parts.
- * @param string URI to be represented
- * @throws TInvalidDataValueException if URI is of bad format
- */
- public function __construct($uri)
- {
- if(($ret=@parse_url($uri))!==false)
- {
- // decoding???
- $this->_scheme=isset($ret['scheme'])?$ret['scheme']:'';
- $this->_host=isset($ret['host'])?$ret['host']:'';
- $this->_port=isset($ret['port'])?$ret['port']:'';
- $this->_user=isset($ret['user'])?$ret['user']:'';
- $this->_pass=isset($ret['pass'])?$ret['pass']:'';
- $this->_path=isset($ret['path'])?$ret['path']:'';
- $this->_query=isset($ret['query'])?$ret['query']:'';
- $this->_fragment=isset($ret['fragment'])?$ret['fragment']:'';
- $this->_uri=$uri;
- }
- else
- {
- throw new TInvalidDataValueException('uri_format_invalid',$uri);
- }
- }
-
- /**
- * @return string URI
- */
- public function getUri()
- {
- return $this->_uri;
- }
-
- /**
- * @return string scheme of the URI, such as 'http', 'https', 'ftp', etc.
- */
- public function getScheme()
- {
- return $this->_scheme;
- }
-
- /**
- * @return string hostname of the URI
- */
- public function getHost()
- {
- return $this->_host;
- }
-
- /**
- * @return integer port number of the URI
- */
- public function getPort()
- {
- return $this->_port;
- }
-
- /**
- * @return string username of the URI
- */
- public function getUser()
- {
- return $this->_user;
- }
-
- /**
- * @return string password of the URI
- */
- public function getPassword()
- {
- return $this->_pass;
- }
-
- /**
- * @return string path of the URI
- */
- public function getPath()
- {
- return $this->_path;
- }
-
- /**
- * @return string query string of the URI
- */
- public function getQuery()
- {
- return $this->_query;
- }
-
- /**
- * @return string fragment of the URI
- */
- public function getFragment()
- {
- return $this->_fragment;
- }
-}
-
-/**
- * THttpRequestUrlFormat class.
- * THttpRequestUrlFormat defines the enumerable type for the possible URL formats
- * that can be recognized by {@link THttpRequest}.
- *
- * The following enumerable values are defined:
- * - Get: the URL format is like /path/to/index.php?name1=value1&name2=value2...
- * - Path: the URL format is like /path/to/index.php/name1,value1/name2,value2...
- * - HiddenPath: the URL format is like /path/to/name1,value1/name2,value2...
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @package System.Web
- * @since 3.0.4
- */
-class THttpRequestUrlFormat extends TEnumerable
-{
- const Get='Get';
- const Path='Path';
- const HiddenPath='HiddenPath';
-}
-
+} \ No newline at end of file