getBody(); case 'headers': return $this->getHeaders(); case 'method': return $this->getMethod(); case 'path': return $this->getPath(); case 'pathParts': return $this->getPathParts(); case 'query': return $this->getQuery(); default: throw new Exception('Property ' . $name . ' does not exist.'); } } public function getBody() { return $this->body; } public function getHeaders() { return $this->headers; } public function getMethod() { return $this->method; } public function getPath() { return $this->path; } public function getPathParts() { return $this->pathParts; } public function getQuery() { return $this->query; } // ------------------------------------------------------------------------- /** * Set instance members based on the HTTP request sent to the server. */ public function readHttpRequest() { $this->body = file_get_contents("php://input"); $this->headers = apache_request_headers(); $this->method = $_SERVER['REQUEST_METHOD']; $uri = parse_url($_SERVER['REQUEST_URI']); $this->path = $uri['path']; $this->pathParts = explode('/', substr($this->path, 1)); $this->query = $_GET; } // readHttpRequest() /** * Return a reference to the singleton instance of the Request derived * from the server's information about the request sent to the script. * * @return Request * @static */ static public function getRequest() { if (!isset(self::$theRequest)) { $klass = __CLASS__; $request = new $klass(); $request->readHttpRequest(); self::$theRequest = $request; } return self::$theRequest; } // getRequest() } ?>