/usr/share/php/Horde/Controller/Request/Http.php is in php-horde-controller 2.0.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | <?php
/**
* @category Horde
* @package Controller
* @author James Pepin <james@bluestatedigital.com>
* @license http://www.horde.org/licenses/bsd BSD
*/
class Horde_Controller_Request_Http implements Horde_Controller_Request
{
/**
* Request path
* @var string
*/
protected $_path;
/**
* All the headers
* @var array
*/
protected $_headers = null;
public function setPath($path)
{
$this->_path = $path;
}
public function getPath()
{
return $this->_path;
}
public function getMethod()
{
$serverVars = $this->getServerVars();
return $serverVars['REQUEST_METHOD'];
}
public function getGetVars()
{
return $_GET;
}
public function getFileVars()
{
return $_FILES;
}
public function getServerVars()
{
return $_SERVER;
}
public function getPostVars()
{
return $_POST;
}
public function getCookieVars()
{
return $_COOKIE;
}
public function getRequestVars()
{
return $_REQUEST;
}
public function getSessionId()
{
//TODO: how do we get session ID?
//should probably be passing it in the constructor, or via setSession
//we should definitely lazy-load sessions though cause we don't always care about it
//perhaps a preFilter to start the session if the controller requests it, and then call setSession on the request
//object
return 0;
}
/**
* Gets the value of header.
*
* Returns the value of the specified request header.
*
* @param string $name the name of the header
* @return string the value of the specified header
*/
public function getHeader($name)
{
if ($this->_headers == null) {
$this->_headers = $this->_getAllHeaders();
}
$name = Horde_String::lower($name);
if (isset($this->_headers[$name])) {
return $this->_headers[$name];
}
return null;
}
/**
* Gets all the header names.
*
* Returns an array of all the header names this request
* contains.
*
* @return array all the available headers as strings
*/
public function getHeaderNames()
{
if ($this->_headers == null) {
$this->_headers = $this->_getAllHeaders();
}
return array_keys($this->_headers);
}
/**
* Gets all the headers.
*
* Returns an associative array of all the header names and values of this
* request.
*
* @return array containing all the headers
*/
public function getHeaders()
{
if ($this->_headers == null) {
$this->_headers = $this->_getAllHeaders();
}
return $this->_headers;
}
/**
* Returns all HTTP_* headers.
*
* Returns all the HTTP_* headers. Works both if PHP is an apache
* module and if it's running as a CGI.
*
* @return array the headers' names and values
*/
private function _getAllHeaders()
{
if (function_exists('getallheaders')) {
return array_change_key_case(getallheaders(), CASE_LOWER);
}
$result = array();
$server = $this->getServerVars();
reset($server);
foreach ($server as $key => $value) {
$header_name = substr($key, 0, 5);
if ($header_name == 'HTTP_') {
$hdr = str_replace('_', '-', Horde_String::lower(substr($key, 5)));
$result[$hdr] = $value;
}
}
return $result;
}
}
|