diff options
Diffstat (limited to '3rdparty/Sabre/HTTP/Request.php')
-rwxr-xr-x[-rw-r--r--] | 3rdparty/Sabre/HTTP/Request.php | 113 |
1 files changed, 69 insertions, 44 deletions
diff --git a/3rdparty/Sabre/HTTP/Request.php b/3rdparty/Sabre/HTTP/Request.php index 95a64171aab..4746ef77704 100644..100755 --- a/3rdparty/Sabre/HTTP/Request.php +++ b/3rdparty/Sabre/HTTP/Request.php @@ -6,74 +6,85 @@ * This object can be used to easily access information about an HTTP request. * It can additionally be used to create 'mock' requests. * - * This class mostly operates indepentend, but because of the nature of a single - * request per run it can operate as a singleton. For more information check out + * This class mostly operates independent, but because of the nature of a single + * request per run it can operate as a singleton. For more information check out * the behaviour around 'defaultInputStream'. * * @package Sabre - * @subpackage HTTP - * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @subpackage HTTP + * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ class Sabre_HTTP_Request { /** * PHP's $_SERVER data - * - * @var string + * + * @var array */ protected $_SERVER; /** + * PHP's $_POST data + * + * @var array + */ + protected $_POST; + + /** * The request body, if any. * * This is stored in the form of a stream resource. * - * @var resource + * @var resource */ protected $body = null; /** * This will be set as the 'default' inputStream for a specific HTTP request - * We sometimes need to retain, or rebuild this if we need multiple runs + * We sometimes need to retain, or rebuild this if we need multiple runs * of parsing the original HTTP request. - * - * @var resource + * + * @var resource */ static $defaultInputStream=null; /** * Sets up the object * - * The serverData array can be used to override usage of PHP's - * global _SERVER variable. - * - * @param array $serverData + * The serverData and postData array can be used to override usage of PHP's + * global _SERVER and _POST variable respectively. + * + * @param array $serverData + * @param array $postData */ - public function __construct($serverData = null) { + public function __construct(array $serverData = null, array $postData = null) { if ($serverData) $this->_SERVER = $serverData; else $this->_SERVER =& $_SERVER; + if ($postData) $this->_POST = $postData; + else $this->_POST =& $_POST; + } /** * Returns the value for a specific http header. * * This method returns null if the header did not exist. - * - * @param string $name - * @return string + * + * @param string $name + * @return string */ public function getHeader($name) { $name = strtoupper(str_replace(array('-'),array('_'),$name)); if (isset($this->_SERVER['HTTP_' . $name])) { return $this->_SERVER['HTTP_' . $name]; - } + } - // There's a few headers that seem to end up in the top-level + // There's a few headers that seem to end up in the top-level // server array. switch($name) { case 'CONTENT_TYPE' : @@ -92,9 +103,9 @@ class Sabre_HTTP_Request { * Returns all (known) HTTP headers. * * All headers are converted to lower-case, and additionally all underscores - * are automatically converted to dashes - * - * @return array + * are automatically converted to dashes + * + * @return array */ public function getHeaders() { @@ -122,9 +133,9 @@ class Sabre_HTTP_Request { /** * Returns the HTTP request method * - * This is for example POST or GET + * This is for example POST or GET * - * @return string + * @return string */ public function getMethod() { @@ -135,18 +146,18 @@ class Sabre_HTTP_Request { /** * Returns the requested uri * - * @return string + * @return string */ public function getUri() { - + return $this->_SERVER['REQUEST_URI']; } /** - * Will return protocol + the hostname + the uri - * - * @return void + * Will return protocol + the hostname + the uri + * + * @return string */ public function getAbsoluteUri() { @@ -157,9 +168,9 @@ class Sabre_HTTP_Request { } /** - * Returns everything after the ? from the current url - * - * @return string + * Returns everything after the ? from the current url + * + * @return string */ public function getQueryString() { @@ -168,13 +179,13 @@ class Sabre_HTTP_Request { } /** - * Returns the HTTP request body body + * Returns the HTTP request body body * * This method returns a readable stream resource. - * If the asString parameter is set to true, a string is sent instead. + * If the asString parameter is set to true, a string is sent instead. * * @param bool asString - * @return resource + * @return resource */ public function getBody($asString = false) { @@ -196,14 +207,14 @@ class Sabre_HTTP_Request { } /** - * Sets the contents of the HTTP request body - * + * Sets the contents of the HTTP request body + * * This method can either accept a string, or a readable stream resource. * - * If the setAsDefaultInputStream is set to true, it means for this run of the + * If the setAsDefaultInputStream is set to true, it means for this run of the * script the supplied body will be used instead of php://input. * - * @param mixed $body + * @param mixed $body * @param bool $setAsDefaultInputStream * @return void */ @@ -226,12 +237,26 @@ class Sabre_HTTP_Request { } /** - * Returns a specific item from the _SERVER array. + * Returns PHP's _POST variable. + * + * The reason this is in a method is so it can be subclassed and + * overridden. + * + * @return array + */ + public function getPostVars() { + + return $this->_POST; + + } + + /** + * Returns a specific item from the _SERVER array. * * Do not rely on this feature, it is for internal use only. * - * @param string $field - * @return string + * @param string $field + * @return string */ public function getRawServerValue($field) { |