_path = $_SERVER['PATH_INFO']; switch ($this->method()) { case 'GET' : $this->_req = new \SparkLib\Application\Request\Get($_GET); break; case 'POST' : $this->_req = new \SparkLib\Application\Request\Post($_POST); break; case 'DELETE' : $this->_req = new \SparkLib\Application\Request\Delete($_REQUEST); break; case 'HEAD' : $this->_req = new \SparkLib\Application\Request\Head($_GET); break; default : $this->_req = new \SparkLib\Application\Request\Get(array()); // fake it for other methods } $this->discernType(); } /** * Initialize and populate sessions. */ public function startSession () { if (! isset($_SESSION)) session_start(); } /** * End the current session. */ public function endSession () { $_SESSION = array(); session_destroy(); } public function method () { return $_SERVER['REQUEST_METHOD']; } public function header ($header) { header($header); } /** * Grab the first thing in the Accepts: header, check it against * a whitelist, and (if it passes) set the expected MIME type of request * to it. This may later be overwritten by a type extension found * on the URL by Application's routing mechanism. * * For now this is defaulting to text/html if we get an unrecognized * type. More appropriate behavior MIGHT be to throw an exception, * but on the other hand it could be that we're going to get a lot of * weird input that we don't want to break on. * * Much to be investigated here. */ protected function discernType () { $accept = $_SERVER['HTTP_ACCEPT']; $types = explode(',', $accept); list($first_type) = explode(';', $types[0]); $first_type = trim($first_type); if (Application::$mimeToExtension[$first_type]) { $this->_req->setType($first_type); } } }