/** * Property getter interceptor to handle the "reason" property special case. * * @param string $property The property to retrieve * * @return mixed */ public function __get($property) { if ($property == 'reason' && isset(self::$codes[$this->code])) { return self::$codes[$this->code]; } return parent::__get($property); }
/** * Property getter interceptor to handle "uri" and "host" special cases. * * @param string $property The property to retrieve * * @return mixed */ public function __get($property) { switch ($property) { case 'uri': if ($this->_uri !== null) { return $this->_uri->getURL(); } return null; case 'proxy': return $this->_proxy; case 'path': if ($this->_uri === null) { return null; } if ($this->httpVersion == self::HTTP_VERSION_1_0 || $this->proxy) { // if http 1.0 or proxy given, the request uri must be absolute return $this->_uri->getURL(); } if (($path = $this->_uri->getPath()) === false) { $path = '/'; } if (($query = $this->_uri->getQuery()) !== false) { $path .= '?' . $query; } if (($fragment = $this->_uri->getFragment()) !== false) { $path .= '#' . $fragment; } return $path; case 'host': if (isset($this->headers['host'])) { return trim($this->headers['host']); } if ($this->_proxy !== null) { return $this->_proxy; } if ($this->_uri !== null) { $host = $this->_uri->getHost(); if (($port = $this->_uri->getPort()) !== false) { $host .= ':' . $port; } } return $host; case 'port': $port = $this->_uri->getPort(); if (!is_numeric($port)) { return $this->isSecure() ? 443 : 80; } return $port; case 'connection': if ($this->_connection === null) { include_once 'HTTP/Connection.php'; $this->_connection = HTTP_Connection::factory('Socket'); } return $this->_connection; default: return parent::__get($property); } }